stacked column chartjs blazor server

Solutions on MaxInterview for stacked column chartjs blazor server by the best coders in the world

showing results for - "stacked column chartjs blazor server"
Aitana
12 Jun 2016
1protected override void OnInitialized()
2{
3    _config = new BarConfig
4    {
5
6        Options = new BarOptions
7        {
8
9            Title = new OptionsTitle
10            {
11                Display = true,
12                Text = "Sample chart from Blazor"
13            },
14            Scales = new BarScales
15            {
16                XAxes = new List<CartesianAxis>
17                 {
18                    new BarCategoryAxis
19                    {
20                        BarThickness = BarThickness.Flex,
21                        Stacked = true
22                    }
23                }
24
25            },
26            Responsive = true
27        }
28    };
29
30    _config.Data.Labels.AddRange(new[] { "Jan", "Feb", "March", "April" });
31
32    var barSet1 = new BarDataset<DoubleWrapper>
33    {
34        Stack = "One",
35        Label = "Income",
36        BackgroundColor = ColorUtil.RandomColorString(),
37        BorderWidth = 1,
38        HoverBackgroundColor = ColorUtil.ColorString(0, 0, 0, 0.1),
39        HoverBorderColor = ColorUtil.RandomColorString(),
40        HoverBorderWidth = 1,
41        BorderColor = "#ffffff",
42    };
43    var barSet1a = new BarDataset<DoubleWrapper>
44    {
45        Stack = "Two",
46        Label = "Expense",
47        BackgroundColor = ColorUtil.RandomColorString(),
48        BorderWidth = 1,
49        HoverBackgroundColor = ColorUtil.ColorString(0, 0, 0, 0.1),
50        HoverBorderColor = ColorUtil.RandomColorString(),
51        HoverBorderWidth = 1,
52        BorderColor = "#ffffff",
53    };
54    barSet1.AddRange(new double[] { 4, 3, 2, 1 }.Wrap());
55    barSet1a.AddRange(new double[] { 10, 20, 13, 5 }.Wrap());
56    _config.Data.Datasets.Add(barSet1);
57    _config.Data.Datasets.Add(barSet1a);
58
59    var barSet2 = new BarDataset<DoubleWrapper>
60    {
61        Stack = "One",
62        Label = "Savings",
63        BackgroundColor = ColorUtil.RandomColorString(),
64        BorderWidth = 1,
65        HoverBackgroundColor = ColorUtil.ColorString(0, 0, 0, 0.1),
66        HoverBorderColor = ColorUtil.RandomColorString(),
67        HoverBorderWidth = 1,
68        BorderColor = "#ffffff",
69    };
70
71    barSet2.AddRange(new double[] { 1, 5, 10, 15 }.Wrap());
72    _config.Data.Datasets.Add(barSet2);
73
74}
75