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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
use super::{LabelFormatter, ValueFormatter};
use animate::{prelude::*, Gradient};
use animate::{Color, TextStyle};

#[derive(Debug, Clone)]
pub enum Fill {
    None,
    Solid(Color),
    Gradient(Gradient),
}

impl Default for Fill {
    fn default() -> Self {
        Self::None
    }
}

pub enum Position {
    Above,
    Middle,
    Below,
    Left,
    Top,
    Bottom,
    Right,
    None,
}

pub trait BaseOption {
    fn animation(&self) -> &AnimationOptions;
    fn colors(&self) -> &Vec<Fill>;
    fn title(&self) -> &TitleOptions;
    fn legend(&self) -> &LegendOptions;
    fn tooltip(&self) -> &TooltipOptions;
    fn background(&self) -> &Fill;
}

pub struct AnimationOptions {
    /// The animation duration in ms.
    pub duration: usize,

    /// String|EasingFunction - Name of a predefined easing function or an
    /// easing function itself.
    ///
    /// See [animation.dart] for the full list of predefined functions.
    pub easing: String,

    /// () -> fn - The function that is called when the animation is complete.
    pub on_end: Option<fn()>,
}

pub struct LegendOptions {
    /// (String label) -> String - A function that format the labels.
    pub label_formatter: Option<LabelFormatter>,

    /// The position of the legend relative to the chart area.
    /// Supported values: "left", "top", "bottom", "right", "none".
    pub position: Position,

    /// An object that controls the styling of the legend.
    pub style: StyleOptions,
}

pub struct TitleOptions {
    /// The position of the title relative to the chart area.
    /// Supported values: "above", "below", "middle", "none";
    pub position: Position,

    /// An object that controls the styling of the chart title.
    pub style: StyleOptions,

    /// The title text. A `null` value means the title is hidden.
    pub text: Option<String>,
}

pub struct TooltipOptions {
    /// bool - Whether to show the tooltip.
    pub enabled: bool,

    /// (String label) -> String - A function that format the labels.
    pub label_formatter: Option<LabelFormatter>,

    /// An object that controls the styling of the tooltip.
    pub style: StyleOptions,

    /// (num value) -> String - A function that formats the values.
    pub value_formatter: Option<ValueFormatter>,
}

#[derive(Debug, Clone)]
pub struct BarChartSeriesOptions {
    /// An object that controls the channel labels.
    /// bool - Whether to show the labels.
    pub labels: Option<StyleOptions>,
}

pub struct BarChartCrosshairOptions {
    /// The fill color of the crosshair.
    pub color: Color,
}

pub struct BarChartXAxisLabelsOptions {
    /// The maximum rotation angle in degrees. Must be <= 90.
    pub max_rotation: i64,

    /// The minimum rotation angle in degrees. Must be >= -90.
    pub min_rotation: i64,

    pub style: StyleOptions,
}

pub struct BarChartXAxisOptions {
    /// An object that controls the crosshair.
    pub crosshair: Option<BarChartCrosshairOptions>,

    /// The color of the horizontal grid lines.
    pub grid_line_color: Color,

    /// The width of the horizontal grid lines.
    pub grid_line_width: f64,

    /// The color of the axis itself.
    pub line_color: Color,

    /// The width of the axis itself.
    pub line_width: f64,

    /// An object that controls the axis labels.
    pub labels: BarChartXAxisLabelsOptions,

    /// The position of the axis relative to the chart area.
    /// Supported values: "bottom".
    pub position: Position,

    /// An object that controls the axis title.
    pub title: TitleOption,
}

pub struct BarChartYAxisLabelsOptions {
    /// (num value) -> String - A function that formats the labels.
    pub formatter: Option<ValueFormatter>,

    /// An object that controls the styling of the axis labels.
    pub style: StyleOptions,
}

pub struct BarChartYAxisOptions {
    /// The color of the vertical grid lines.
    pub grid_line_color: Color,

    /// The width of the vertical grid lines.
    pub grid_line_width: f64,

    /// The color of the axis itself.
    pub line_color: Color,

    /// The width of the axis itself.
    pub line_width: f64,

    /// The interval of the tick marks in axis unit. If `null`, this value
    /// is automatically calculated.
    pub interval: Option<f64>,

    /// An object that controls the axis labels.
    pub labels: BarChartYAxisLabelsOptions,

    /// The desired maximum value on the axis. If set, the calculated value
    /// is guaranteed to be >= this value.
    pub max_value: Option<usize>,

    /// The minimum interval. If `null`, this value is automatically
    /// calculated.
    pub min_interval: Option<f64>,

    /// The desired minimum value on the axis. If set, the calculated value
    /// is guaranteed to be <= this value.
    pub min_value: Option<usize>,

    /// The position of the axis relative to the chart area.
    /// Supported values: "left".
    pub position: Position,

    /// An object that controls the axis title.
    pub title: TitleOption,
}

pub struct BarChartOptions {
    /// An object that controls the channel.
    pub channel: BarChartSeriesOptions,

    /// An object that controls the x-axis.
    pub xaxis: BarChartXAxisOptions,

    /// An object that controls the y-axis.
    pub yaxis: BarChartYAxisOptions,

    /// An object that controls the animation.
    pub animation: AnimationOptions,

    /// The background color of the chart.
    pub background: Fill,

    /// The color list used to render the channel. If there are more channel than
    /// colors, the colors will be reused.
    pub colors: Vec<Fill>,

    /// An object that controls the legend.
    pub legend: LegendOptions,

    /// An object that controls the chart title.
    pub title: TitleOptions,

    /// An object that controls the tooltip.
    pub tooltip: TooltipOptions,
}

impl BaseOption for BarChartOptions {
    fn animation(&self) -> &AnimationOptions {
        &self.animation
    }

    fn colors(&self) -> &Vec<Fill> {
        &self.colors
    }

    fn title(&self) -> &TitleOptions {
        &self.title
    }

    fn legend(&self) -> &LegendOptions {
        &self.legend
    }

    fn tooltip(&self) -> &TooltipOptions {
        &self.tooltip
    }

    fn background(&self) -> &Fill {
        &self.background
    }
}

pub struct TitleOption {
    /// An object that controls the styling of the axis title.
    pub style: StyleOptions,

    /// The title text. A `null` value means the title is hidden.
    pub text: Option<String>,
}

impl Default for BarChartOptions {
    fn default() -> Self {
        Self {
            channel: BarChartSeriesOptions { labels: None },
            xaxis: BarChartXAxisOptions {
                crosshair: None,
                grid_line_color: color::GRAY_5,
                grid_line_width: 1.,
                line_color: color::GRAY_5,
                line_width: 1.,
                labels: BarChartXAxisLabelsOptions {
                    max_rotation: 0,
                    min_rotation: -90,
                    style: Default::default(),
                },
                position: Position::Bottom,
                title: TitleOption {
                    style: Default::default(),
                    text: None,
                },
            },
            yaxis: BarChartYAxisOptions {
                grid_line_color: color::GRAY_5,
                grid_line_width: 0.,
                line_color: color::GRAY_5,
                line_width: 0.,
                interval: None,
                labels: BarChartYAxisLabelsOptions {
                    formatter: None,
                    style: Default::default(),
                },
                max_value: None,
                min_interval: None,
                min_value: None,
                position: Position::Left,
                title: TitleOption {
                    style: Default::default(),
                    text: None,
                },
            },
            animation: AnimationOptions {
                duration: 800,
                easing: "easeOutQuint".into(),
                on_end: None,
            },
            background: Fill::Solid(color::WHITE),
            colors: vec![
                Fill::Solid(Color::rgb(0x7c, 0xb5, 0xec)),
                Fill::Solid(Color::rgb(0x43, 0x43, 0x48)),
                Fill::Solid(Color::rgb(0x90, 0xed, 0x7d)),
                Fill::Solid(Color::rgb(0xf7, 0xa3, 0x5c)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe9)),
                Fill::Solid(Color::rgb(0xf1, 0x5c, 0x80)),
                Fill::Solid(Color::rgb(0xe4, 0xd3, 0x54)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe8)),
                Fill::Solid(Color::rgb(0x8d, 0x46, 0x53)),
                Fill::Solid(Color::rgb(0x91, 0xe8, 0xe1)),
            ],
            legend: LegendOptions {
                label_formatter: None,
                position: Position::Right,
                style: Default::default(),
            },
            title: TitleOptions {
                position: Position::Above,
                style: Default::default(),
                text: None,
            },
            tooltip: TooltipOptions {
                enabled: true,
                label_formatter: None,
                style: Default::default(),
                value_formatter: None,
            },
        }
    }
}

#[derive(Debug, Clone)]
pub struct StyleOptions {
    pub background: Color,
    pub border_color: Color,
    pub border_width: f64, // i32?
    /// The title"s color
    pub color: Color,
    /// The title"s font family.
    pub fontfamily: Option<String>,
    /// The title"s font size.
    pub fontsize: Option<f64>,
    /// The title"s font style.
    pub fontstyle: Option<TextStyle>,
}

impl Default for StyleOptions {
    fn default() -> Self {
        Self {
            background: color::WHITE,
            border_color: color::GRAY_4,
            border_width: 0_f64,
            color: color::GRAY_9,
            fontfamily: Some("Roboto".into()),
            fontsize: Some(12_f64),
            fontstyle: Some(TextStyle::Normal),
        }
    }
}

pub struct GaugeChartOptions {
    /// An object that controls the gauge labels.
    /// Whether to show the labels
    /// An object that controls the styling of the gauge labels
    pub labels: Option<StyleOptions>,

    /// An object that controls the animation.
    pub animation: AnimationOptions,

    /// The background color of the chart.
    pub background: Fill,

    /// The background color of the gauge.
    pub gauge_background: Color,

    /// The color list used to render the channel. If there are more channel than
    /// colors, the colors will be reused.
    pub colors: Vec<Fill>,

    /// An object that controls the legend.
    pub legend: LegendOptions,

    /// An object that controls the chart title.
    pub title: TitleOptions,

    /// An object that controls the tooltip.
    pub tooltip: TooltipOptions,
}

impl BaseOption for GaugeChartOptions {
    fn animation(&self) -> &AnimationOptions {
        &self.animation
    }

    fn colors(&self) -> &Vec<Fill> {
        &self.colors
    }

    fn title(&self) -> &TitleOptions {
        &self.title
    }

    fn legend(&self) -> &LegendOptions {
        &self.legend
    }

    fn tooltip(&self) -> &TooltipOptions {
        &self.tooltip
    }

    fn background(&self) -> &Fill {
        &self.background
    }
}

impl Default for GaugeChartOptions {
    fn default() -> Self {
        Self {
            labels: Default::default(),
            animation: AnimationOptions {
                duration: 800,
                easing: "easeOutQuint".into(),
                on_end: None,
            },
            background: Fill::Solid(color::WHITE),
            gauge_background: color::GRAY_3,
            colors: vec![
                Fill::Solid(Color::rgb(0x7c, 0xb5, 0xec)),
                Fill::Solid(Color::rgb(0x43, 0x43, 0x48)),
                Fill::Solid(Color::rgb(0x90, 0xed, 0x7d)),
                Fill::Solid(Color::rgb(0xf7, 0xa3, 0x5c)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe9)),
                Fill::Solid(Color::rgb(0xf1, 0x5c, 0x80)),
                Fill::Solid(Color::rgb(0xe4, 0xd3, 0x54)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe8)),
                Fill::Solid(Color::rgb(0x8d, 0x46, 0x53)),
                Fill::Solid(Color::rgb(0x91, 0xe8, 0xe1)),
            ],
            legend: LegendOptions {
                label_formatter: None,
                position: Position::Right,
                style: Default::default(),
            },
            title: TitleOptions {
                position: Position::Above,
                style: Default::default(),
                text: None,
            },
            tooltip: TooltipOptions {
                enabled: true,
                label_formatter: None,
                style: Default::default(),
                value_formatter: None,
            },
        }
    }
}

pub struct LineChartSeriesMarkersOptions {
    /// bool - Whether markers are enabled.
    pub enabled: bool,

    /// The fill color. If `null`, the stroke color of the channel
    /// will be used.
    pub fill_color: Option<Fill>,

    /// The line width of the markers.
    pub line_width: usize,

    /// The stroke color. If `null`, the stroke color of the channel
    /// will be used.
    pub stroke_color: Option<Fill>,

    /// Size of the markers.
    pub size: f64,
}

pub struct LineChartSeriesOptions {
    /// The curve tension. The typical value is from 0.3 to 0.5.
    /// To draw straight lines, set this to zero.
    pub curve_tension: f64,

    /// The opacity of the area between a channel and the x-axis.
    pub fill_opacity: f64,

    /// The line width of the channel.
    pub line_width: f64,

    /// An object that controls the channel labels.
    /// Whether to show the labels
    pub labels: Option<StyleOptions>,

    /// An object that controls the markers.
    pub markers: LineChartSeriesMarkersOptions,
}

pub struct LineChartXAxisLabelsOptions {
    /// The maximum rotation angle in degrees. Must be <= 90.
    pub max_rotation: i64,

    /// The minimum rotation angle in degrees. Must be >= -90.
    pub min_rotation: i64,

    pub style: StyleOptions,
}

pub struct LineChartXAxisOptions {
    /// The color of the horizontal grid lines.
    pub grid_line_color: Color,

    /// The width of the horizontal grid lines.
    pub grid_line_width: f64,

    /// The color of the axis itself.
    pub line_color: Color,

    /// The width of the axis itself.
    pub line_width: f64,

    /// An object that controls the axis labels.
    pub labels: LineChartXAxisLabelsOptions,

    /// The position of the axis relative to the chart area.
    /// Supported values: "bottom".
    pub position: Position,

    /// An object that controls the axis title.
    pub title: TitleOption,
}

pub struct LineChartYAxisLabelsOptions {
    /// (num value) -> String - A function that formats the labels.
    pub formatter: Option<ValueFormatter>,

    /// An object that controls the styling of the axis labels.
    pub style: StyleOptions,
}
pub struct LineChartYAxisOptions {
    /// The color of the vertical grid lines.
    pub grid_line_color: Color,

    /// The width of the vertical grid lines.
    pub grid_line_width: f64,

    /// The color of the axis itself.
    pub line_color: Color,

    /// The width of the axis itself.
    pub line_width: f64,

    /// The interval of the tick marks in axis unit. If `null`, this value
    /// is automatically calculated.
    pub interval: Option<f64>,

    /// An object that controls the axis labels.
    pub labels: LineChartYAxisLabelsOptions,

    /// The desired maximum value on the axis. If set, the calculated value
    /// is guaranteed to be >= this value.
    pub max_value: Option<usize>,

    /// The minimum interval. If `null`, this value is automatically
    /// calculated.
    pub min_interval: Option<f64>,

    /// The desired minimum value on the axis. If set, the calculated value
    /// is guaranteed to be <= this value.
    pub min_value: Option<usize>,

    /// The position of the axis relative to the chart area.
    /// Supported values: "left".
    pub position: Position,

    /// An object that controls the axis title.
    pub title: TitleOption,
}

pub struct LineChartOptions {
    /// An object that controls the channel.
    pub channel: LineChartSeriesOptions,

    /// An object that controls the x-axis.
    pub xaxis: LineChartXAxisOptions,

    /// An object that controls the y-axis.
    pub yaxis: LineChartYAxisOptions,

    /// An object that controls the animation.
    pub animation: AnimationOptions,

    /// The background color of the chart.
    pub background: Fill,

    /// The color list used to render the channel. If there are more channel than
    /// colors, the colors will be reused.
    pub colors: Vec<Fill>,

    /// An object that controls the legend.
    pub legend: LegendOptions,

    /// An object that controls the chart title.
    pub title: TitleOptions,

    /// An object that controls the tooltip.
    pub tooltip: TooltipOptions,
}

impl BaseOption for LineChartOptions {
    fn animation(&self) -> &AnimationOptions {
        &self.animation
    }

    fn colors(&self) -> &Vec<Fill> {
        &self.colors
    }

    fn title(&self) -> &TitleOptions {
        &self.title
    }

    fn legend(&self) -> &LegendOptions {
        &self.legend
    }

    fn tooltip(&self) -> &TooltipOptions {
        &self.tooltip
    }

    fn background(&self) -> &Fill {
        &self.background
    }
}

impl Default for LineChartOptions {
    fn default() -> Self {
        Self {
            channel: LineChartSeriesOptions {
                curve_tension: 0.4,
                fill_opacity: 0.25,
                line_width: 2_f64,
                labels: None,
                markers: LineChartSeriesMarkersOptions {
                    enabled: true,
                    fill_color: None,
                    line_width: 1,
                    stroke_color: Some(Fill::Solid(color::WHITE)),
                    size: 4.,
                },
            },
            xaxis: LineChartXAxisOptions {
                grid_line_color: color::GRAY_5,
                grid_line_width: 1.,
                line_color: color::GRAY_5,
                line_width: 1.,
                labels: LineChartXAxisLabelsOptions {
                    max_rotation: 0,
                    min_rotation: -90,
                    style: Default::default(),
                },
                position: Position::Bottom,
                title: TitleOption {
                    style: Default::default(),
                    text: None,
                },
            },
            yaxis: LineChartYAxisOptions {
                grid_line_color: color::GRAY_5,
                grid_line_width: 0.,
                line_color: color::GRAY_5,
                line_width: 0.,
                interval: None,
                labels: LineChartYAxisLabelsOptions {
                    formatter: None,
                    style: Default::default(),
                },
                max_value: None,
                min_interval: None,
                min_value: None,
                position: Position::Left,
                title: TitleOption {
                    style: Default::default(),
                    text: None,
                },
            },
            animation: AnimationOptions {
                duration: 800,
                easing: "easeOutQuint".into(),
                on_end: None,
            },
            background: Fill::Solid(color::WHITE),
            colors: vec![
                Fill::Solid(Color::rgb(0x7c, 0xb5, 0xec)),
                Fill::Solid(Color::rgb(0x43, 0x43, 0x48)),
                Fill::Solid(Color::rgb(0x90, 0xed, 0x7d)),
                Fill::Solid(Color::rgb(0xf7, 0xa3, 0x5c)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe9)),
                Fill::Solid(Color::rgb(0xf1, 0x5c, 0x80)),
                Fill::Solid(Color::rgb(0xe4, 0xd3, 0x54)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe8)),
                Fill::Solid(Color::rgb(0x8d, 0x46, 0x53)),
                Fill::Solid(Color::rgb(0x91, 0xe8, 0xe1)),
            ],
            legend: LegendOptions {
                label_formatter: None,
                position: Position::Right,
                style: Default::default(),
            },
            title: TitleOptions {
                position: Position::Above,
                style: Default::default(),
                text: None,
            },
            tooltip: TooltipOptions {
                enabled: true,
                label_formatter: None,
                style: Default::default(),
                value_formatter: None,
            },
        }
    }
}

pub struct PieChartSeriesLabelsOptions {
    /// bool - Whether to show the labels.
    pub enabled: bool,

    /// (num) -> String - A function used to format the labels.
    pub formatter: Option<ValueFormatter>,

    pub style: StyleOptions,
}

pub struct PieChartSeriesOptions {
    /// bool - Whether to draw the slices counterclockwise.
    pub counterclockwise: bool,

    /// An object that controls the channel labels.
    pub labels: PieChartSeriesLabelsOptions,

    /// The start angle in degrees. Default is -90, which is 12 o'clock.
    pub start_angle: f64,
}

pub struct PieChartOptions {
    /// If between 0 and 1, displays a donut chart. The hole will have a
    /// radius equal to this value times the radius of the chart.
    pub pie_hole: f64,

    /// An object that controls the channel.
    pub channel: PieChartSeriesOptions,

    /// An object that controls the animation.
    pub animation: AnimationOptions,

    /// The background color of the chart.
    pub background: Fill,

    /// The color list used to render the channel. If there are more channel than
    /// colors, the colors will be reused.
    pub colors: Vec<Fill>,

    /// An object that controls the legend.
    pub legend: LegendOptions,

    /// An object that controls the chart title.
    pub title: TitleOptions,

    /// An object that controls the tooltip.
    pub tooltip: TooltipOptions,
}

impl BaseOption for PieChartOptions {
    fn animation(&self) -> &AnimationOptions {
        &self.animation
    }

    fn colors(&self) -> &Vec<Fill> {
        &self.colors
    }

    fn title(&self) -> &TitleOptions {
        &self.title
    }

    fn legend(&self) -> &LegendOptions {
        &self.legend
    }

    fn tooltip(&self) -> &TooltipOptions {
        &self.tooltip
    }

    fn background(&self) -> &Fill {
        &self.background
    }
}

impl Default for PieChartOptions {
    fn default() -> Self {
        Self {
            pie_hole: 0_f64,
            channel: PieChartSeriesOptions {
                counterclockwise: false,
                labels: PieChartSeriesLabelsOptions {
                    enabled: false,
                    formatter: None,
                    style: Default::default(),
                },
                start_angle: -90_f64,
            },
            animation: AnimationOptions {
                duration: 800,
                easing: "easeOutQuint".into(),
                on_end: None,
            },
            background: Fill::Solid(color::WHITE),
            colors: vec![
                Fill::Solid(Color::rgb(0x7c, 0xb5, 0xec)),
                Fill::Solid(Color::rgb(0x43, 0x43, 0x48)),
                Fill::Solid(Color::rgb(0x90, 0xed, 0x7d)),
                Fill::Solid(Color::rgb(0xf7, 0xa3, 0x5c)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe9)),
                Fill::Solid(Color::rgb(0xf1, 0x5c, 0x80)),
                Fill::Solid(Color::rgb(0xe4, 0xd3, 0x54)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe8)),
                Fill::Solid(Color::rgb(0x8d, 0x46, 0x53)),
                Fill::Solid(Color::rgb(0x91, 0xe8, 0xe1)),
            ],
            legend: LegendOptions {
                label_formatter: None,
                position: Position::Right,
                style: Default::default(),
            },
            title: TitleOptions {
                position: Position::Above,
                style: Default::default(),
                text: None,
            },
            tooltip: TooltipOptions {
                enabled: true,
                label_formatter: None,
                style: Default::default(),
                value_formatter: None,
            },
        }
    }
}

pub struct RadarChartSeriesMarkersOptions {
    /// bool - Whether markers are enabled.
    pub enabled: bool,

    /// The fill color. If `null`, the stroke color of the channel
    /// will be used.
    pub fill_color: Option<Fill>,

    /// The line width of the markers.
    pub line_width: f64,

    /// The stroke color. If `null`, the stroke color of the channel
    /// will be used.
    pub stroke_color: Option<Fill>,

    /// Size of the markers. To disable markers, set this to zero.
    pub size: f64,
}

pub struct RadarChartSeriesOptions {
    /// The opacity of the area between a channel and the x-axis.
    pub fill_opacity: f64,

    /// The line width of the channel.
    pub line_width: f64,

    /// An object that controls the channel labels.
    ///   Whether to show the labels.
    pub labels: Option<StyleOptions>,

    /// An object that controls the markers.
    pub markers: RadarChartSeriesMarkersOptions,
}

pub struct RadarChartXAxisLabelsOptions {
    /// (num value) -> String - A function that formats the labels.
    pub formatter: Option<ValueFormatter>,

    /// An object that controls the styling of the axis labels.
    pub style: StyleOptions,
}

pub struct RadarChartXAxisOptions {
    /// The color of the horizontal grid lines.
    pub grid_line_color: Color,

    /// The width of the horizontal grid lines.
    pub grid_line_width: f64,

    /// An object that controls the axis labels.
    pub labels: RadarChartXAxisLabelsOptions,
}

pub struct RadarChartYAxisLabelsOptions {
    /// (num value) -> String - A function that formats the labels.
    pub formatter: Option<ValueFormatter>,

    /// An object that controls the styling of the axis labels.
    pub style: StyleOptions,
}

pub struct RadarChartYAxisOptions {
    /// The color of the vertical grid lines.
    pub grid_line_color: Color,

    /// The width of the vertical grid lines.
    pub grid_line_width: f64,

    /// The interval of the tick marks in axis unit. If `null`, this value
    /// is automatically calculated.
    pub interval: Option<f64>,

    /// An object that controls the axis labels.
    pub labels: RadarChartYAxisLabelsOptions,

    /// The minimum interval. If `null`, this value is automatically
    /// calculated.
    pub min_interval: Option<f64>,
}

pub struct RadarChartOptions {
    // An object that controls the channel.
    pub channel: RadarChartSeriesOptions,

    /// An object that controls the x-axis.
    pub xaxis: RadarChartXAxisOptions,

    /// An object that controls the y-axis.
    pub yaxis: RadarChartYAxisOptions,

    /// An object that controls the animation.
    pub animation: AnimationOptions,

    /// The background color of the chart.
    pub background_color: Fill,

    /// The color list used to render the channel. If there are more channel than
    /// colors, the colors will be reused.
    pub colors: Vec<Fill>,

    /// An object that controls the legend.
    pub legend: LegendOptions,

    /// An object that controls the chart title.
    pub title: TitleOptions,

    /// An object that controls the tooltip.
    pub tooltip: TooltipOptions,
}

impl BaseOption for RadarChartOptions {
    fn animation(&self) -> &AnimationOptions {
        &self.animation
    }

    fn colors(&self) -> &Vec<Fill> {
        &self.colors
    }

    fn title(&self) -> &TitleOptions {
        &self.title
    }

    fn legend(&self) -> &LegendOptions {
        &self.legend
    }

    fn tooltip(&self) -> &TooltipOptions {
        &self.tooltip
    }

    fn background(&self) -> &Fill {
        &self.background_color
    }
}

impl Default for RadarChartOptions {
    fn default() -> Self {
        Self {
            channel: RadarChartSeriesOptions {
                fill_opacity: 0.25,
                line_width: 2.,
                labels: None,
                markers: RadarChartSeriesMarkersOptions {
                    enabled: true,
                    fill_color: None,
                    line_width: 1.,
                    stroke_color: Some(Fill::Solid(color::WHITE)),
                    size: 4.,
                },
            },
            xaxis: RadarChartXAxisOptions {
                grid_line_color: color::GRAY_5,
                grid_line_width: 1_f64,
                labels: RadarChartXAxisLabelsOptions {
                    formatter: None,
                    style: Default::default(),
                },
            },
            yaxis: RadarChartYAxisOptions {
                grid_line_color: color::GRAY_5,
                grid_line_width: 1_f64,
                interval: None,
                labels: RadarChartYAxisLabelsOptions {
                    formatter: None,
                    style: Default::default(),
                },
                min_interval: None,
            },
            animation: AnimationOptions {
                duration: 800,
                easing: "easeOutQuint".into(),
                on_end: None,
            },
            background_color: Fill::Solid(color::WHITE),
            colors: vec![
                Fill::Solid(Color::rgb(0x7c, 0xb5, 0xec)),
                Fill::Solid(Color::rgb(0x43, 0x43, 0x48)),
                Fill::Solid(Color::rgb(0x90, 0xed, 0x7d)),
                Fill::Solid(Color::rgb(0xf7, 0xa3, 0x5c)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe9)),
                Fill::Solid(Color::rgb(0xf1, 0x5c, 0x80)),
                Fill::Solid(Color::rgb(0xe4, 0xd3, 0x54)),
                Fill::Solid(Color::rgb(0x80, 0x85, 0xe8)),
                Fill::Solid(Color::rgb(0x8d, 0x46, 0x53)),
                Fill::Solid(Color::rgb(0x91, 0xe8, 0xe1)),
            ],
            legend: LegendOptions {
                label_formatter: None,
                position: Position::Right,
                style: Default::default(),
            },
            title: TitleOptions {
                position: Position::Above,
                style: Default::default(),
                text: None,
            },
            tooltip: TooltipOptions {
                enabled: true,
                label_formatter: None,
                style: Default::default(),
                value_formatter: None,
            },
        }
    }
}