forked from plotly/plotly.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
3515 lines (3214 loc) · 113 KB
/
mod.rs
File metadata and controls
3515 lines (3214 loc) · 113 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
pub mod themes;
pub mod update_menu;
use std::borrow::Cow;
use plotly_derive::FieldSetter;
use serde::{Serialize, Serializer};
use update_menu::UpdateMenu;
use crate::common::Domain;
use crate::{
color::Color,
common::{
Anchor, AxisSide, Calendar, ColorBar, ColorScale, DashType, ExponentFormat, Font, Label,
Orientation, TickFormatStop, TickMode, Title,
},
private::{NumOrString, NumOrStringCollection},
};
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum AxisType {
#[serde(rename = "-")]
Default,
Linear,
Log,
Date,
Category,
MultiCategory,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum AxisConstrain {
Range,
Domain,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ConstrainDirection {
Left,
Center,
Right,
Top,
Middle,
Bottom,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum RangeMode {
Normal,
ToZero,
NonNegative,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum TicksDirection {
Outside,
Inside,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum TicksPosition {
Labels,
Boundaries,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ArrayShow {
All,
First,
Last,
None,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum BarMode {
Stack,
Group,
Overlay,
Relative,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum BarNorm {
#[serde(rename = "")]
Empty,
Fraction,
Percent,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum BoxMode {
Group,
Overlay,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ViolinMode {
Group,
Overlay,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum WaterfallMode {
Group,
Overlay,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum TraceOrder {
Reversed,
Grouped,
#[serde(rename = "reversed+grouped")]
ReversedGrouped,
Normal,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ItemSizing {
Trace,
Constant,
}
#[derive(Debug, Clone)]
pub enum ItemClick {
Toggle,
ToggleOthers,
False,
}
impl Serialize for ItemClick {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match *self {
Self::Toggle => serializer.serialize_str("toggle"),
Self::ToggleOthers => serializer.serialize_str("toggleothers"),
Self::False => serializer.serialize_bool(false),
}
}
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum GroupClick {
ToggleItem,
ToggleGroup,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct Legend {
#[serde(rename = "bgcolor")]
background_color: Option<Box<dyn Color>>,
#[serde(rename = "bordercolor")]
border_color: Option<Box<dyn Color>>,
#[serde(rename = "borderwidth")]
border_width: Option<usize>,
font: Option<Font>,
orientation: Option<Orientation>,
#[serde(rename = "traceorder")]
trace_order: Option<TraceOrder>,
#[serde(rename = "tracegroupgap")]
trace_group_gap: Option<usize>,
#[serde(rename = "itemsizing")]
item_sizing: Option<ItemSizing>,
#[serde(rename = "itemclick")]
item_click: Option<ItemClick>,
#[serde(rename = "itemdoubleclick")]
item_double_click: Option<ItemClick>,
x: Option<f64>,
#[serde(rename = "xanchor")]
x_anchor: Option<Anchor>,
y: Option<f64>,
#[serde(rename = "yanchor")]
y_anchor: Option<Anchor>,
valign: Option<VAlign>,
title: Option<Title>,
#[serde(rename = "groupclick")]
group_click: Option<GroupClick>,
#[serde(rename = "itemwidth")]
item_width: Option<usize>,
}
impl Legend {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum VAlign {
Top,
Middle,
Bottom,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum HAlign {
Left,
Center,
Right,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct Margin {
#[serde(rename = "l")]
left: Option<usize>,
#[serde(rename = "r")]
right: Option<usize>,
#[serde(rename = "t")]
top: Option<usize>,
#[serde(rename = "b")]
bottom: Option<usize>,
pad: Option<usize>,
#[serde(rename = "autoexpand")]
auto_expand: Option<bool>,
}
impl Margin {
pub fn new() -> Self {
Default::default()
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct LayoutColorScale {
sequential: Option<ColorScale>,
#[serde(rename = "sequentialminus")]
sequential_minus: Option<ColorScale>,
diverging: Option<ColorScale>,
}
impl LayoutColorScale {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum SliderRangeMode {
Auto,
Fixed,
Match,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct RangeSliderYAxis {
#[serde(rename = "rangemode")]
range_mode: Option<SliderRangeMode>,
range: Option<NumOrStringCollection>,
}
impl RangeSliderYAxis {
pub fn new() -> Self {
Default::default()
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct RangeSlider {
#[serde(rename = "bgcolor")]
background_color: Option<Box<dyn Color>>,
#[serde(rename = "bordercolor")]
border_color: Option<Box<dyn Color>>,
#[serde(rename = "borderwidth")]
border_width: Option<u64>,
#[serde(rename = "autorange")]
auto_range: Option<bool>,
range: Option<NumOrStringCollection>,
thickness: Option<f64>,
visible: Option<bool>,
#[serde(rename = "yaxis")]
y_axis: Option<RangeSliderYAxis>,
}
impl RangeSlider {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum SelectorStep {
Month,
Year,
Day,
Hour,
Minute,
Second,
All,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum StepMode {
Backward,
ToDate,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct SelectorButton {
visible: Option<bool>,
step: Option<SelectorStep>,
#[serde(rename = "stepmode")]
step_mode: Option<StepMode>,
count: Option<usize>,
label: Option<String>,
name: Option<String>,
#[serde(rename = "templateitemname")]
template_item_name: Option<String>,
}
impl SelectorButton {
pub fn new() -> Self {
Default::default()
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct RangeSelector {
visible: Option<bool>,
buttons: Option<Vec<SelectorButton>>,
x: Option<f64>,
#[serde(rename = "xanchor")]
x_anchor: Option<Anchor>,
y: Option<f64>,
#[serde(rename = "yanchor")]
y_anchor: Option<Anchor>,
font: Option<Font>,
#[serde(rename = "bgcolor")]
background_color: Option<Box<dyn Color>>,
#[serde(rename = "activecolor")]
active_color: Option<Box<dyn Color>>,
#[serde(rename = "bordercolor")]
border_color: Option<Box<dyn Color>>,
#[serde(rename = "borderwidth")]
border_width: Option<usize>,
}
impl RangeSelector {
pub fn new() -> Self {
Default::default()
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct ColorAxis {
cauto: Option<bool>,
cmin: Option<f64>,
cmax: Option<f64>,
cmid: Option<f64>,
#[serde(rename = "colorscale")]
color_scale: Option<ColorScale>,
#[serde(rename = "autocolorscale")]
auto_color_scale: Option<bool>,
#[serde(rename = "reversescale")]
reverse_scale: Option<bool>,
#[serde(rename = "showscale")]
show_scale: Option<bool>,
#[serde(rename = "colorbar")]
color_bar: Option<ColorBar>,
}
impl ColorAxis {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum SpikeMode {
ToAxis,
Across,
Marker,
#[serde(rename = "toaxis+across")]
ToaxisAcross,
#[serde(rename = "toaxis+marker")]
ToAxisMarker,
#[serde(rename = "across+marker")]
AcrossMarker,
#[serde(rename = "toaxis+across+marker")]
ToaxisAcrossMarker,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum SpikeSnap {
Data,
Cursor,
#[serde(rename = "hovered data")]
HoveredData,
}
#[derive(Serialize, Debug, Clone)]
pub enum CategoryOrder {
#[serde(rename = "trace")]
Trace,
#[serde(rename = "category ascending")]
CategoryAscending,
#[serde(rename = "category descending")]
CategoryDescending,
#[serde(rename = "array")]
Array,
#[serde(rename = "total ascending")]
TotalAscending,
#[serde(rename = "total descending")]
TotalDescending,
#[serde(rename = "min ascending")]
MinAscending,
#[serde(rename = "min descending")]
MinDescending,
#[serde(rename = "max ascending")]
MaxAscending,
#[serde(rename = "max descending")]
MaxDescending,
#[serde(rename = "sum ascending")]
SumAscending,
#[serde(rename = "sum descending")]
SumDescending,
#[serde(rename = "mean ascending")]
MeanAscending,
#[serde(rename = "mean descending")]
MeanDescending,
#[serde(rename = "geometric mean ascending")]
GeometricMeanAscending,
#[serde(rename = "geometric mean descending")]
GeometricMeanDescending,
#[serde(rename = "median ascending")]
MedianAscending,
#[serde(rename = "median descending")]
MedianDescending,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct Axis {
visible: Option<bool>,
/// Sets the order in which categories on this axis appear. Only has an
/// effect if `category_order` is set to [`CategoryOrder::Array`].
/// Used with `category_order`.
#[serde(rename = "categoryarray")]
category_array: Option<NumOrStringCollection>,
/// Specifies the ordering logic for the case of categorical variables.
/// By default, plotly uses [`CategoryOrder::Trace`], which specifies
/// the order that is present in the data supplied. Set `category_order` to
/// [`CategoryOrder::CategoryAscending`] or
/// [`CategoryOrder::CategoryDescending`] if order should be determined
/// by the alphanumerical order of the category names. Set `category_order`
/// to [`CategoryOrder::Array`] to derive the ordering from the attribute
/// `category_array`. If a category is not found in the `category_array`
/// array, the sorting behavior for that attribute will be identical to the
/// [`CategoryOrder::Trace`] mode. The unspecified categories will follow
/// the categories in `category_array`. Set `category_order` to
/// [`CategoryOrder::TotalAscending`] or
/// [`CategoryOrder::TotalDescending`] if order should be determined by the
/// numerical order of the values. Similarly, the order can be determined
/// by the min, max, sum, mean, geometric mean or median of all the values.
#[serde(rename = "categoryorder")]
category_order: Option<CategoryOrder>,
color: Option<Box<dyn Color>>,
title: Option<Title>,
#[field_setter(skip)]
r#type: Option<AxisType>,
#[serde(rename = "autorange")]
auto_range: Option<bool>,
#[serde(rename = "rangemode")]
range_mode: Option<RangeMode>,
range: Option<NumOrStringCollection>,
#[serde(rename = "fixedrange")]
fixed_range: Option<bool>,
constrain: Option<AxisConstrain>,
#[serde(rename = "constraintoward")]
constrain_toward: Option<ConstrainDirection>,
#[serde(rename = "tickmode")]
tick_mode: Option<TickMode>,
#[serde(rename = "nticks")]
n_ticks: Option<usize>,
#[serde(rename = "scaleanchor")]
scale_anchor: Option<String>,
#[serde(rename = "scaleratio")]
scale_ratio: Option<f64>,
tick0: Option<f64>,
dtick: Option<f64>,
#[field_setter(skip)]
matches: Option<String>,
#[serde(rename = "tickvals")]
tick_values: Option<Vec<f64>>,
#[serde(rename = "ticktext")]
tick_text: Option<Vec<String>>,
ticks: Option<TicksDirection>,
#[serde(rename = "tickson")]
ticks_on: Option<TicksPosition>,
mirror: Option<bool>,
#[serde(rename = "ticklen")]
tick_length: Option<usize>,
#[serde(rename = "tickwidth")]
tick_width: Option<usize>,
#[serde(rename = "tickcolor")]
tick_color: Option<Box<dyn Color>>,
#[serde(rename = "showticklabels")]
show_tick_labels: Option<bool>,
#[serde(rename = "automargin")]
auto_margin: Option<bool>,
#[serde(rename = "showspikes")]
show_spikes: Option<bool>,
#[serde(rename = "spikecolor")]
spike_color: Option<Box<dyn Color>>,
#[serde(rename = "spikethickness")]
spike_thickness: Option<usize>,
#[serde(rename = "spikedash")]
spike_dash: Option<DashType>,
#[serde(rename = "spikemode")]
spike_mode: Option<SpikeMode>,
#[serde(rename = "spikesnap")]
spike_snap: Option<SpikeSnap>,
#[serde(rename = "tickfont")]
tick_font: Option<Font>,
#[serde(rename = "tickangle")]
tick_angle: Option<f64>,
#[serde(rename = "tickprefix")]
tick_prefix: Option<String>,
#[serde(rename = "showtickprefix")]
show_tick_prefix: Option<ArrayShow>,
#[serde(rename = "ticksuffix")]
tick_suffix: Option<String>,
#[serde(rename = "showticksuffix")]
show_tick_suffix: Option<ArrayShow>,
#[serde(rename = "showexponent")]
show_exponent: Option<ArrayShow>,
#[serde(rename = "exponentformat")]
exponent_format: Option<ExponentFormat>,
#[serde(rename = "separatethousands")]
separate_thousands: Option<bool>,
#[serde(rename = "tickformat")]
tick_format: Option<String>,
#[serde(rename = "tickformatstops")]
tick_format_stops: Option<Vec<TickFormatStop>>,
#[serde(rename = "hoverformat")]
hover_format: Option<String>,
#[serde(rename = "showline")]
show_line: Option<bool>,
#[serde(rename = "linecolor")]
line_color: Option<Box<dyn Color>>,
#[serde(rename = "linewidth")]
line_width: Option<usize>,
#[serde(rename = "showgrid")]
show_grid: Option<bool>,
#[serde(rename = "gridcolor")]
grid_color: Option<Box<dyn Color>>,
#[serde(rename = "gridwidth")]
grid_width: Option<usize>,
#[serde(rename = "zeroline")]
zero_line: Option<bool>,
#[serde(rename = "zerolinecolor")]
zero_line_color: Option<Box<dyn Color>>,
#[serde(rename = "zerolinewidth")]
zero_line_width: Option<usize>,
#[serde(rename = "showdividers")]
show_dividers: Option<bool>,
#[serde(rename = "dividercolor")]
divider_color: Option<Box<dyn Color>>,
#[serde(rename = "dividerwidth")]
divider_width: Option<usize>,
anchor: Option<String>,
side: Option<AxisSide>,
overlaying: Option<String>,
#[field_setter(skip)]
domain: Option<Vec<f64>>,
position: Option<f64>,
#[serde(rename = "rangeslider")]
range_slider: Option<RangeSlider>,
#[serde(rename = "rangeselector")]
range_selector: Option<RangeSelector>,
calendar: Option<Calendar>,
}
impl Axis {
pub fn new() -> Self {
Default::default()
}
pub fn matches(mut self, matches: &str) -> Self {
self.matches = Some(matches.to_string());
self
}
pub fn type_(mut self, t: AxisType) -> Self {
self.r#type = Some(t);
self
}
pub fn domain(mut self, domain: &[f64]) -> Self {
self.domain = Some(domain.to_vec());
self
}
}
#[derive(Serialize, Debug, Clone)]
pub enum RowOrder {
#[serde(rename = "top to bottom")]
TopToBottom,
#[serde(rename = "bottom to top")]
BottomToTop,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum GridPattern {
Independent,
Coupled,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum GridXSide {
Bottom,
#[serde(rename = "bottom plot")]
BottomPlot,
#[serde(rename = "top plot")]
TopPlot,
Top,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum GridYSide {
Left,
#[serde(rename = "left plot")]
LeftPlot,
#[serde(rename = "right plot")]
RightPlot,
Right,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct GridDomain {
x: Option<Vec<f64>>,
y: Option<Vec<f64>>,
}
impl GridDomain {
pub fn new() -> Self {
Default::default()
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct LayoutGrid {
rows: Option<usize>,
#[serde(rename = "roworder")]
row_order: Option<RowOrder>,
columns: Option<usize>,
#[serde(rename = "subplots")]
sub_plots: Option<Vec<String>>,
#[serde(rename = "xaxes")]
x_axes: Option<Vec<String>>,
#[serde(rename = "yaxes")]
y_axes: Option<Vec<String>>,
pattern: Option<GridPattern>,
#[serde(rename = "xgap")]
x_gap: Option<f64>,
#[serde(rename = "ygap")]
y_gap: Option<f64>,
domain: Option<GridDomain>,
#[serde(rename = "xside")]
x_side: Option<GridXSide>,
#[serde(rename = "yside")]
y_side: Option<GridYSide>,
}
impl LayoutGrid {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Debug, Clone)]
pub enum UniformTextMode {
False,
Hide,
Show,
}
impl Serialize for UniformTextMode {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match *self {
Self::False => serializer.serialize_bool(false),
Self::Hide => serializer.serialize_str("hide"),
Self::Show => serializer.serialize_str("show"),
}
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct UniformText {
mode: Option<UniformTextMode>,
#[serde(rename = "minsize")]
min_size: Option<usize>,
}
impl UniformText {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Debug, Clone)]
pub enum HoverMode {
X,
Y,
Closest,
False,
XUnified,
YUnified,
}
impl Serialize for HoverMode {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match *self {
Self::X => serializer.serialize_str("x"),
Self::Y => serializer.serialize_str("y"),
Self::Closest => serializer.serialize_str("closest"),
Self::False => serializer.serialize_bool(false),
Self::XUnified => serializer.serialize_str("x unified"),
Self::YUnified => serializer.serialize_str("y unified"),
}
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct ModeBar {
orientation: Option<Orientation>,
#[serde(rename = "bgcolor")]
background_color: Option<Box<dyn Color>>,
color: Option<Box<dyn Color>>,
#[serde(rename = "activecolor")]
active_color: Option<Box<dyn Color>>,
}
impl ModeBar {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ShapeType {
Circle,
Rect,
Path,
Line,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ShapeLayer {
Below,
Above,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ShapeSizeMode {
Scaled,
Pixel,
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum FillRule {
EvenOdd,
NonZero,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct ShapeLine {
/// Sets the line color.
color: Option<Box<dyn Color>>,
/// Sets the line width (in px).
width: Option<f64>,
/// Sets the dash style of lines. Set to a dash type string ("solid", "dot",
/// "dash", "longdash", "dashdot", or "longdashdot") or a dash length
/// list in px (eg "5px,10px,2px,2px").
dash: Option<DashType>,
}
impl ShapeLine {
pub fn new() -> Self {
Default::default()
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct Shape {
/// Determines whether or not this shape is visible.
visible: Option<bool>,
#[field_setter(skip)]
r#type: Option<ShapeType>,
/// Specifies whether shapes are drawn below or above traces.
layer: Option<ShapeLayer>,
/// Sets the shape's x coordinate axis. If set to an x axis id (e.g. "x" or
/// "x2"), the `x` position refers to an x coordinate. If set to
/// "paper", the `x` position refers to the distance from the left side
/// of the plotting area in normalized coordinates where "0" ("1")
/// corresponds to the left (right) side. If the axis `type` is "log", then
/// you must take the log of your desired range. If the axis `type` is
/// "date", then you must convert the date to unix time in milliseconds.
#[serde(rename = "xref")]
x_ref: Option<String>,
/// Sets the shapes's sizing mode along the x axis. If set to "scaled",
/// `x0`, `x1` and x coordinates within `path` refer to data values on
/// the x axis or a fraction of the plot area's width (`xref` set to
/// "paper"). If set to "pixel", `xanchor` specifies the x position
/// in terms of data or plot fraction but `x0`, `x1` and x coordinates
/// within `path` are pixels relative to `xanchor`. This way, the shape
/// can have a fixed width while maintaining a position relative to data
/// or plot fraction.
#[serde(rename = "xsizemode")]
x_size_mode: Option<ShapeSizeMode>,
/// Only relevant in conjunction with `xsizemode` set to "pixel". Specifies
/// the anchor point on the x axis to which `x0`, `x1` and x coordinates
/// within `path` are relative to. E.g. useful to attach a pixel sized
/// shape to a certain data value. No effect when `xsizemode` not set to
/// "pixel".
#[serde(rename = "xanchor")]
x_anchor: Option<NumOrString>,
/// Sets the shape's starting x position. See `type` and `xsizemode` for
/// more info.
x0: Option<NumOrString>,
/// Sets the shape's end x position. See `type` and `xsizemode` for more
/// info.
x1: Option<NumOrString>,
/// Sets the annotation's y coordinate axis. If set to an y axis id (e.g.
/// "y" or "y2"), the `y` position refers to an y coordinate If set to
/// "paper", the `y` position refers to the distance from the bottom of
/// the plotting area in normalized coordinates where "0" ("1")
/// corresponds to the bottom (top).
#[serde(rename = "yref")]
y_ref: Option<String>,
/// Sets the shapes's sizing mode along the y axis. If set to "scaled",
/// `y0`, `y1` and y coordinates within `path` refer to data values on
/// the y axis or a fraction of the plot area's height (`yref` set to
/// "paper"). If set to "pixel", `yanchor` specifies the y position
/// in terms of data or plot fraction but `y0`, `y1` and y coordinates
/// within `path` are pixels relative to `yanchor`. This way, the shape
/// can have a fixed height while maintaining a position relative to
/// data or plot fraction.
#[serde(rename = "ysizemode")]
y_size_mode: Option<ShapeSizeMode>,
/// Only relevant in conjunction with `ysizemode` set to "pixel". Specifies
/// the anchor point on the y axis to which `y0`, `y1` and y coordinates
/// within `path` are relative to. E.g. useful to attach a pixel sized
/// shape to a certain data value. No effect when `ysizemode` not set to
/// "pixel".
#[serde(rename = "yanchor")]
y_anchor: Option<NumOrString>,
/// Sets the shape's starting y position. See `type` and `ysizemode` for
/// more info.
y0: Option<NumOrString>,
/// Sets the shape's end y position. See `type` and `ysizemode` for more
/// info.
y1: Option<NumOrString>,
/// For `type` "path" - a valid SVG path with the pixel values replaced by
/// data values in `xsizemode`/`ysizemode` being "scaled" and taken
/// unmodified as pixels relative to `xanchor` and `yanchor` in case of
/// "pixel" size mode. There are a few restrictions / quirks
/// only absolute instructions, not relative. So the allowed segments
/// are: M, L, H, V, Q, C, T, S, and Z arcs (A) are not allowed because
/// radius rx and ry are relative. In the future we could consider
/// supporting relative commands, but we would have to decide on how to
/// handle date and log axes. Note that even as is, Q and C Bezier paths
/// that are smooth on linear axes may not be smooth on log, and vice versa.
/// no chained "polybezier" commands - specify the segment type for each
/// one. On category axes, values are numbers scaled to the serial
/// numbers of categories because using the categories themselves
/// there would be no way to describe fractional positions On data axes:
/// because space and T are both normal components of path strings, we
/// can't use either to separate date from time parts. Therefore we'll
/// use underscore for this purpose: 2015-02-21_13:45:56.789
path: Option<String>,
/// Sets the opacity of the shape. Number between or equal to 0 and 1.
opacity: Option<f64>,
/// Sets the shape line properties (`color`, `width`, `dash`).
line: Option<ShapeLine>,
/// Sets the color filling the shape's interior. Only applies to closed
/// shapes.
#[serde(rename = "fillcolor")]
fill_color: Option<Box<dyn Color>>,
/// Determines which regions of complex paths constitute the interior. For
/// more info please visit <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule>
#[serde(rename = "fillrule")]
fill_rule: Option<FillRule>,
/// Determines whether the shape could be activated for edit or not. Has no
/// effect when the older editable shapes mode is enabled via
/// `config.editable` or `config.edits.shapePosition`.
editable: Option<bool>,
/// When used in a template, named items are created in the output figure in
/// addition to any items the figure already has in this array. You can
/// modify these items in the output figure by making your own item with
/// `templateitemname` matching this `name` alongside your modifications
/// (including `visible: false` or `enabled: false` to hide it). Has no
/// effect outside of a template.
name: Option<String>,
/// Used to refer to a named item in this array in the template. Named items
/// from the template will be created even without a matching item in
/// the input figure, but you can modify one by making an item with
/// `templateitemname` matching its `name`, alongside your modifications
/// (including `visible: false` or `enabled: false` to hide it). If there is
/// no template or no matching item, this item will be hidden unless you
/// explicitly show it with `visible: true`.
#[serde(rename = "templateitemname")]
template_item_name: Option<String>,
}
impl Shape {
pub fn new() -> Self {
Default::default()
}
/// Specifies the shape type to be drawn. If "line", a line is drawn from
/// (`x0`,`y0`) to (`x1`,`y1`) with respect to the axes' sizing mode. If
/// "circle", a circle is drawn from ((`x0`+`x1`)/2, (`y0`+`y1`)/2))
/// with radius (|(`x0`+`x1`)/2 - `x0`|, |(`y0`+`y1`)/2 -`y0`)|)
/// with respect to the axes' sizing mode. If "rect", a rectangle is drawn
/// linking (`x0`,`y0`), (`x1`,`y0`), (`x1`,`y1`), (`x0`,`y1`),
/// (`x0`,`y0`) with respect to the axes' sizing mode. If "path", draw a
/// custom SVG path using `path`. with respect to the axes' sizing mode.
pub fn shape_type(mut self, shape_type: ShapeType) -> Self {
self.r#type = Some(shape_type);
self
}
}
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum DrawDirection {
Ortho,
Horizontal,
Vertical,
Diagonal,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Debug, Clone, FieldSetter)]
pub struct NewShape {
/// Sets the shape line properties (`color`, `width`, `dash`).
line: Option<ShapeLine>,
/// Sets the color filling new shapes' interior. Please note that if using a
/// fillcolor with alpha greater than half, drag inside the active shape
/// starts moving the shape underneath, otherwise a new shape could be
/// started over.
#[serde(rename = "fillcolor")]
fill_color: Option<Box<dyn Color>>,
/// Determines the path's interior. For more info please
/// visit <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule>
#[serde(rename = "fillrule")]