Ejemplo n.º 1
0
        public void ToString_Returns_Correct_Rgba_String_Representation()
        {
            byte   red   = 4;
            byte   green = 65;
            byte   blue  = 154;
            double alpha = 0.232;

            string expectedString = $"rgba({red}, {green}, {blue}, {alpha})";

            var color        = ChartColor.FromRgba(red, green, blue, alpha);
            var actualString = color.ToString();

            Assert.AreEqual(expectedString, actualString);
        }
Ejemplo n.º 2
0
        public void ToString_Comma_Culture_Returns_Correct_Rgba_String_Representation()
        {
            byte   red   = 4;
            byte   green = 65;
            byte   blue  = 154;
            double alpha = 0.232;

            CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-NL");
            string expectedString = $"rgba({red}, {green}, {blue}, {alpha.ToString(CultureInfo.InvariantCulture)})";

            var color        = ChartColor.FromRgba(red, green, blue, alpha);
            var actualString = color.ToString();

            Assert.AreEqual(expectedString, actualString);
        }
Ejemplo n.º 3
0
        public static Chart BuildTemperatureAttributesBubbleChart1(List <TemperatureOrigin> temperatureOrigins)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Bubble;

            var data = new Data();

            List <Dataset> datasets = new List <Dataset>();

            ChartColor[] colors = { Colors.GetRedBorder(), Colors.GetBlueBorder(), Colors.GetGreenBorder() };

            int j = 0;

            for (int i = 0; i < temperatureOrigins.Count; i++)
            {
                var dataset        = new BubbleDataset();
                var bubbleDataList = new List <BubbleData>();
                foreach (var temp in temperatureOrigins[i].TemperatureAtts)
                {
                    TimeSpan t          = (temp.Time - new DateTime(1970, 1, 1));
                    var      bubbleData = new BubbleData
                    {
                        X = (int)t.TotalSeconds,
                        Y = temp.Temp,
                        R = 5
                    };
                    bubbleDataList.Add(bubbleData);
                }
                dataset.Data        = bubbleDataList;
                dataset.BorderColor = new List <ChartColor> {
                    colors[j++]
                };
                dataset.BackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgba(255, 255, 255, 0.2)
                };
                dataset.Label = temperatureOrigins[i].Origin;
                datasets.Add(dataset);
            }

            data.Datasets = datasets;

            FixTimeLabels(chart.Options);

            chart.Data = data;

            return(chart);
        }
Ejemplo n.º 4
0
 private LineChartDataset <double> GetLoadTimeLineChartDataset()
 {
     return(new LineChartDataset <double>
     {
         Label = L["LoadTime"].Value,
         Data = MonitorWithDetails.LoadTimes,
         BackgroundColor = new List <string> {
             ChartColor.FromRgba(0, 218, 197, 0.2f)
         },
         BorderColor = new List <string> {
             ChartColor.FromRgba(0, 218, 197, 1f)
         },
         Fill = true,
         PointRadius = 2,
         BorderDash = new List <int> {
         }
     });
 }
Ejemplo n.º 5
0
        async Task RefreshUI(SourceHistory history)
        {
            var labels = history.HistoryData
                         .Select(d => d.TimeStampUtc.LocalDateTime.ToString("d.M."))
                         .Reverse()
                         .ToArray();

            var dataSupplies = history.HistoryData
                               .Select(d => {
                // Item 0 = supplies in kg (label "supplies")
                string value = d.DataItems[0].Value.ToString();
                double.TryParse(value, out double supplies);
                return(supplies);
            })
                               .Reverse()
                               .ToList();

            var currentSupplies = $"Vorrat: {dataSupplies.Last():0.0}kg";

            var dataSetPelletSupplies = new LineChartDataset <double>
            {
                Label           = currentSupplies,
                Data            = dataSupplies,
                BackgroundColor = new List <string> {
                    ChartColor.FromRgba(226, 228, 242, 0.8f)
                },
                BorderColor = new List <string> {
                    ChartColor.FromRgba(95, 104, 188, 0.5f)
                },
                Fill        = true,
                PointRadius = 2,
                BorderDash  = new List <int> {
                }
            };

            await lineChart.Clear();

            await lineChart.AddLabel(labels);

            await lineChart.AddDataSet(dataSetPelletSupplies);

            await lineChart.Update();
        }
Ejemplo n.º 6
0
        private LineChartDataset <Point> GetLineChartDataset()
        {
            List <string> backgroundColors = new List <string> {
                ChartColor.FromRgba(195, 171, 214, 0.2f)
            };
            List <string> borderColors = new List <string> {
                ChartColor.FromRgba(195, 171, 214, 0.8f)
            };

            return(new LineChartDataset <Point>
            {
                Data = new List <Point>()
                {
                },
                BackgroundColor = backgroundColors,
                BorderColor = borderColors,
                Fill = true,
                PointRadius = 2,
                BorderDash = new List <int> {
                }
            });
        }
Ejemplo n.º 7
0
        private static Chart GetTimePerDayChart(Dictionary <string, double> timePerDay)
        {
            var chart = new Chart {
                Type = Enums.ChartType.HorizontalBar
            };
            var data = new ChartJSCore.Models.Data
            {
                Labels = timePerDay.Keys.ToList()
            };
            var dataset = new BarDataset
            {
                Label       = "# hours watched",
                Data        = new List <double?>(timePerDay.Values.Select(x => (double?)x)),
                BorderWidth = new List <int> {
                    1
                },
                BackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgba(229, 9, 20, 0.8)
                },
                Type = Enums.ChartType.HorizontalBar,
            };

            data.Datasets = new List <Dataset> {
                dataset
            };
            chart.Data    = data;
            chart.Options = new Options
            {
                Responsive          = true,
                MaintainAspectRatio = false,
                Title = new Title {
                    Text = "Hours watched per day", Display = true
                },
                ResponsiveAnimationDuration = 500
            };

            return(chart);
        }
Ejemplo n.º 8
0
        private static Chart GetHourlyActivityChart(Dictionary <TimeSpan, double> timePerTimeOfDay)
        {
            var labels = timePerTimeOfDay.Keys.Select(x => x.IsFullHour() ? x.ToString("hh':'mm") : "");

            var chart = new Chart {
                Type = Enums.ChartType.Radar
            };
            var data = new ChartJSCore.Models.Data {
                Labels = labels.ToList()
            };
            var dataset = new RadarDataset
            {
                Label           = "# hours watched",
                Data            = new List <double?>(timePerTimeOfDay.Values.Select(x => (double?)x)),
                BorderWidth     = 1,
                BackgroundColor = ChartColor.FromRgba(229, 9, 20, 0.8),
                Type            = Enums.ChartType.Radar
            };

            data.Datasets = new List <Dataset> {
                dataset
            };
            chart.Data    = data;
            chart.Options = new RadarOptions
            {
                Responsive          = true,
                MaintainAspectRatio = false,
                Title = new Title {
                    Text = "Hours watched per time of day", Display = true
                },
                ResponsiveAnimationDuration = 500,
                Tooltips = new ToolTip {
                    Enabled = false
                }
            };

            return(chart);
        }
Ejemplo n.º 9
0
 public static ChartColor GetRed()
 {
     return(ChartColor.FromRgba(255, 99, 132, 0.2));
 }
Ejemplo n.º 10
0
        public static Chart BuildTemperatureAttributesBubbleChart(TemperatureOrigin temperatureOrigins, ChartColor color1, ChartColor color2)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Bubble;

            var data = new Data();

            List <Dataset> datasets = new List <Dataset>();

            ChartColor[] colors = { Colors.GetRed(), Colors.GetRedBorder(), Colors.GetBlue(), Colors.GetBlueBorder(), Colors.GetGreen(), Colors.GetGreenBorder() };

            int j = 0;


            var dataset        = new BubbleDataset();
            var bubbleDataList = new List <BubbleData>();

            foreach (var temp in temperatureOrigins.TemperatureAtts)
            {
                TimeSpan t          = (temp.Time - new DateTime(1970, 1, 1));
                var      bubbleData = new BubbleData
                {
                    X = (int)t.TotalSeconds,
                    Y = temp.Temp,
                    R = 5
                };
                bubbleDataList.Add(bubbleData);
            }
            dataset.Data        = bubbleDataList;
            dataset.BorderColor = new List <ChartColor> {
                color1
            };
            dataset.BackgroundColor = new List <ChartColor> {
                ChartColor.FromRgba(255, 255, 255, 0.2)
            };
            dataset.Label = "TEMP";
            datasets.Add(dataset);

            var dewpDataset     = new BubbleDataset();
            var bubbleDataList2 = new List <BubbleData>();

            foreach (var temp in temperatureOrigins.TemperatureAtts)
            {
                TimeSpan t          = (temp.Time - new DateTime(1970, 1, 1));
                var      bubbleData = new BubbleData
                {
                    X = (int)t.TotalSeconds,
                    Y = temp.Dewp,
                    R = 5
                };
                bubbleDataList2.Add(bubbleData);
            }
            dewpDataset.Data        = bubbleDataList2;
            dewpDataset.Label       = "DEWP";
            dewpDataset.BorderColor = new List <ChartColor> {
                color2
            };
            dewpDataset.BackgroundColor = new List <ChartColor> {
                ChartColor.FromRgba(255, 255, 255, 0.2)
            };
            datasets.Add(dewpDataset);


            data.Datasets = new List <Dataset> {
                dataset, dewpDataset
            };

            FixTimeLabels(chart.Options);

            chart.Data = data;

            return(chart);
        }
Ejemplo n.º 11
0
 public static ChartColor GetOrange()
 {
     return(ChartColor.FromRgba(255, 159, 64, 0.2));
 }
Ejemplo n.º 12
0
        public Chart GenerateLineChart()
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Line;

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
            data.Labels = new List <string>()
            {
                "January", "February", "March", "April", "May", "June", "July"
            };

            LineDataset dataset = new LineDataset()
            {
                Label = "My First dataset",
                Data  = new List <double?>()
                {
                    65, 59, 80, 81, 56, 55, 40
                },
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgba(75, 192, 192, 1),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor>()
                {
                    ChartColor.FromRgba(75, 192, 192, 1)
                },
                PointBackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromHexString("#fff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromRgba(75, 192, 192, 1)
                },
                PointHoverBorderColor = new List <ChartColor>()
                {
                    ChartColor.FromRgba(220, 220, 220, 1)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            Options options = new Options()
            {
                Scales = new Scales()
            };

            Scales scales = new Scales()
            {
                YAxes = new List <Scale>()
                {
                    new CartesianScale()
                }
            };

            CartesianScale yAxes = new CartesianScale()
            {
                Ticks = new Tick()
            };

            Tick tick = new Tick()
            {
                Callback = "function(value, index, values) {return '$' + value;}"
            };

            yAxes.Ticks  = tick;
            scales.YAxes = new List <Scale>()
            {
                yAxes
            };
            options.Scales = scales;
            chart.Options  = options;

            chart.Data = data;

            return(chart);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Retourne le graphique intégré à l'espace administrauter: nombre de nouvelles notes par mois
        /// </summary>
        /// <param name="nbMonths">Nombre de mois avant celui en cours</param>
        /// <param name="Notes">Liste de notes</param>
        public static Chart GenerateChartNotes(int nbMonths, List <Note> Notes)
        {
            List <string>  monthLabels = new List <string>();
            List <double?> noteCounter = new List <double?>();
            DateTime       dateVar     = DateTime.Now;

            for (int i = 0; i < nbMonths; i++) // Création d'une liste de mois, contenant les n mois inférieurs à celui en cours
            {
                monthLabels.Add(dateVar.ToString("MM/yyyy"));
                dateVar = dateVar.AddMonths(-1);
            }
            monthLabels.Reverse();

            foreach (string monthY in monthLabels) // Création du set de données du graphique
            {
                int nbNotes = 0;
                foreach (Note note in Notes)
                {
                    if (note.DateCreation.Month.ToString("00") + "/" + note.DateCreation.Year.ToString("0000") == monthY)
                    {
                        nbNotes++;
                    }
                }
                noteCounter.Add(nbNotes);
            }

            Chart chart = new Chart
            {
                Type = Enums.ChartType.Line
            };

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data
            {
                Labels = monthLabels
            };

            LineDataset dataset = new LineDataset() // Paramètrage du graphique
            {
                Label            = "Créations",
                Data             = noteCounter,
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

            data.Datasets = new List <Dataset>
            {
                dataset
            };

            chart.Data = data;
            return(chart);
        }
Ejemplo n.º 14
0
 public static ChartColor GetYellow()
 {
     return(ChartColor.FromRgba(255, 205, 86, 0.2));
 }
Ejemplo n.º 15
0
 public static ChartColor GetPurple()
 {
     return(ChartColor.FromRgba(153, 102, 255, 0.2));
 }
Ejemplo n.º 16
0
        private static Chart GenerateLineChart()
        {
            var chart = new Chart {
                Type = Enums.ChartType.Line
            };

            var data = new Data
            {
                Labels = new List <string>
                {
                    "January",
                    "February",
                    "March",
                    "April",
                    "May",
                    "June",
                    "July"
                }
            };

            var dataset = new LineDataset
            {
                Label = "My First dataset",
                Data  = new List <double> {
                    65, 59, 80, 81, 56, 55, 40
                },
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

            data.Datasets = new List <Dataset> {
                dataset
            };

            var options = new Options
            {
                Scales = new Scales()
            };

            var scales = new Scales
            {
                YAxes = new List <Scale>
                {
                    new CartesianScale()
                }
            };

            var yAxes = new CartesianScale
            {
                Ticks = new Tick()
            };

            var tick = new Tick
            {
                Callback = "function(value, index, values) {return '$' + value;}"
            };

            yAxes.Ticks  = tick;
            scales.YAxes = new List <Scale> {
                yAxes
            };
            options.Scales = scales;
            chart.Options  = options;

            chart.Data = data;
            return(chart);
        }
Ejemplo n.º 17
0
        public async Task <IViewComponentResult> InvokeAsync(List <string> paramsList)
        {
            var generateChartTask = Task.Run(function: () =>
            {
                if (!_context.SimulationJobs.Any())
                {
                    return(null);
                }

                Chart chart    = new Chart();
                ChartColors cc = new ChartColors();
                // charttype
                chart.Type    = Enums.ChartType.Scatter;
                var simConfig = _context.SimulationConfigurations.Single(predicate: a => a.Id == Convert.ToInt32(paramsList[0]));
                // use available hight in Chart
                var maxY      = Math.Floor(d: (decimal)simConfig.SimulationEndTime / 1000) * 1000;
                var maxX      = 100;
                chart.Options = new LineOptions()
                {
                    MaintainAspectRatio = false,
                    Responsive          = true,
                    Scales = new Scales
                    {
                        YAxes = new List <Scale> {
                            new CartesianScale {
                                Id      = "first-y-axis", Type = "linear", Display = true
                                , Ticks = new CartesianLinearTick {
                                    Max = maxX, Min = 0, Display = true
                                }
                                , ScaleLabel = new ScaleLabel {
                                    LabelString = "Quantity", Display = true, FontSize = 12
                                }
                            }
                        },
                        XAxes = new List <Scale> {
                            new CartesianScale {
                                Id      = "first-x-axis", Type = "linear", Display = true
                                , Ticks = new CartesianLinearTick {
                                    Max = Convert.ToInt32(value: maxY), Min = 0, Display = true
                                }
                                , ScaleLabel = new ScaleLabel {
                                    LabelString = "Time in min", Display = true, FontSize = 12
                                }
                            }
                        }
                    },
                    Legend = new Legend {
                        Position = "bottom", Display = true, FullWidth = true
                    },
                    Title = new Title {
                        Text = "Order Evolution", Position = "top", FontSize = 24, FontStyle = "bold"
                    }
                };


                SimulationType simType = (paramsList[index: 1].Equals(value: "Decentral")) ? SimulationType.Decentral : SimulationType.Central;
                var kpis = _context.SimulationOrders.Where(predicate: x => x.SimulationConfigurationId == Convert.ToInt32(paramsList[0]) &&
                                                           x.SimulationNumber == Convert.ToInt32(paramsList[2]) &&
                                                           x.SimulationType == simType &&
                                                           x.FinishingTime != 0); // filter unfinished orders

                var data = new Data {
                    Datasets = new List <Dataset>()
                };

                var startVal = 0;
                var ts       = simConfig.DynamicKpiTimeSpan;
                var input    = new List <LineScatterData> {
                    new LineScatterData {
                        X = "0", Y = "0"
                    }
                };
                var progress = new List <LineScatterData> {
                    new LineScatterData {
                        X = "0", Y = "0"
                    }
                };
                var output = new List <LineScatterData> {
                    new LineScatterData {
                        X = "0", Y = "0"
                    }
                };
                for (var i = ts; i < simConfig.SimulationEndTime; i = i + ts)
                {
                    input.AddRange(collection: kpis.Where(predicate: x => x.CreationTime >= startVal &&
                                                          x.CreationTime < i)
                                   .Select(selector: x => new { time = i, value = (decimal)x.Name.Count() })
                                   .GroupBy(keySelector: g => g.time)
                                   .Select(selector: n => new LineScatterData {
                        X = Convert.ToDouble(n.Key).ToString(), Y = Convert.ToDouble(n.Count()).ToString()
                    }).ToList());

                    progress.AddRange(collection: kpis.Where(predicate: x => x.CreationTime <= i &&
                                                             x.FinishingTime > i)
                                      .Select(selector: x => new { time = i, value = x.Name.Count() })
                                      .GroupBy(keySelector: g => g.time)
                                      .Select(selector: n => new LineScatterData {
                        X = Convert.ToDouble(n.Key).ToString(), Y = Convert.ToDouble(n.Count()).ToString()
                    }).ToList());

                    output.AddRange(collection: kpis.Where(predicate: x => x.FinishingTime >= startVal &&
                                                           x.FinishingTime < i)
                                    .Select(selector: x => new { time = i, value = x.Name.Count() })
                                    .GroupBy(keySelector: g => g.time)
                                    .Select(selector: n => new LineScatterData {
                        X = Convert.ToDouble(n.Key).ToString(), Y = Convert.ToDouble(n.Count()).ToString()
                    }).ToList());
                    startVal = i;
                }

                data.Datasets.Add(item: new LineScatterDataset()
                {
                    Data = new List <LineScatterData> {
                        new LineScatterData {
                            X = "0", Y = maxX.ToString()
                        }, new LineScatterData {
                            X = simConfig.SettlingStart.ToString(), Y = maxX.ToString()
                        }
                    },
                    BorderWidth     = 1,
                    Label           = "Settling time",
                    BackgroundColor = ChartColor.FromRgba(0, 0, 0, 0.1),
                    BorderColor     = ChartColor.FromRgba(0, 0, 0, 0.3),
                    ShowLine        = true,
                    Fill            = "true",
                    //SteppedLine = false,
                    LineTension = 0,
                    PointRadius = new List <int> {
                        0, 0
                    }
                });

                data.Datasets.Add(item: new LineScatterDataset()
                {
                    Data            = input,
                    BorderWidth     = 3,
                    Label           = "Input",
                    BackgroundColor = cc.Color[index: 3],
                    BorderColor     = cc.Color[index: 3],
                    ShowLine        = true,
                    Fill            = "false",
                    //SteppedLine = false,
                    LineTension = 0.5
                });

                data.Datasets.Add(item: new LineScatterDataset()
                {
                    Data            = progress,
                    BorderWidth     = 3,
                    Label           = "Processing",
                    BackgroundColor = cc.Color[index: 0],
                    BorderColor     = cc.Color[index: 0],
                    ShowLine        = true,
                    Fill            = "false",
                    //SteppedLine = false,
                    LineTension = 0.5
                });

                data.Datasets.Add(item: new LineScatterDataset()
                {
                    Data            = output,
                    BorderWidth     = 3,
                    Label           = "Output",
                    BackgroundColor = cc.Color[index: 2],
                    BorderColor     = cc.Color[index: 2],
                    Fill            = "false",
                    ShowLine        = true,
                    //SteppedLine = false,
                    LineTension = 0.5
                });



                chart.Data = data;
                return(chart);
            });

            // create JS to Render Chart.
            ViewData[index : "chart"] = await generateChartTask;
            ViewData[index : "Type"]  = paramsList[index : 1];
            return(View(viewName: $"OrderEvolution"));
        }
Ejemplo n.º 18
0
        public Chart GeneratePointsOfStudentsBarChart()
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Bar;

            Data data = new Data();
            List <StudentExam> studentExams = _studentExamManager.GetAll().ToList();

            List <string> studentNames = new List <string>();

            foreach (var item in studentExams)
            {
                studentNames.Add(item.Student.FullName);
            }

            data.Labels = studentNames;

            List <double> scores = new List <double>();

            foreach (var item in studentExams)
            {
                scores.Add(item.Points);
            }

            BarDataset dataset = new BarDataset()
            {
                Label           = "Score",
                Data            = scores,
                BackgroundColor = new List <ChartColor>
                {
                    ChartColor.FromRgba(255, 99, 132, 0.2),
                    ChartColor.FromRgba(54, 162, 235, 0.2),
                    ChartColor.FromRgba(255, 206, 86, 0.2),
                    ChartColor.FromRgba(75, 192, 192, 0.2),
                    ChartColor.FromRgba(153, 102, 255, 0.2),
                    ChartColor.FromRgba(255, 159, 64, 0.2)
                },
                BorderColor = new List <ChartColor>
                {
                    ChartColor.FromRgb(255, 99, 132),
                    ChartColor.FromRgb(54, 162, 235),
                    ChartColor.FromRgb(255, 206, 86),
                    ChartColor.FromRgb(75, 192, 192),
                    ChartColor.FromRgb(153, 102, 255),
                    ChartColor.FromRgb(255, 159, 64)
                },
                BorderWidth = new List <int>()
                {
                    1
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            chart.Data = data;

            var options = new Options
            {
                Scales = new Scales()
            };

            var scales = new Scales
            {
                YAxes = new List <Scale>
                {
                    new CartesianScale
                    {
                        Ticks = new CartesianLinearTick
                        {
                            BeginAtZero = true
                        }
                    }
                },
                XAxes = new List <Scale>
                {
                    new BarScale
                    {
                        BarPercentage   = 0.5,
                        BarThickness    = 6,
                        MaxBarThickness = 8,
                        MinBarLength    = 2,
                        GridLines       = new GridLine()
                        {
                            OffsetGridLines = true
                        }
                    }
                }
            };

            options.Scales = scales;

            chart.Options = options;

            chart.Options.Layout = new Layout
            {
                Padding = new Padding
                {
                    PaddingObject = new PaddingObject
                    {
                        Left  = 10,
                        Right = 12
                    }
                }
            };

            return(chart);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 1st = Param[0] = SimulationId
        /// 2st = Param[1] = SimulationType
        /// 3nd = Param[2] = SimulationNumber
        /// </summary>
        /// <param name="paramsList"></param>
        /// <returns></returns>
        public async Task <IViewComponentResult> InvokeAsync(List <string> paramsList)
        {
            // Determine Type and Data
            _simList.Add(item: new Tuple <int, SimulationType>(item1: Convert.ToInt32(value: paramsList[index: 0]), item2: (paramsList[index: 1] == "Central") ? SimulationType.Central : SimulationType.Decentral));
            if (paramsList.Count() == 8)
            {
                _simList.Add(item: new Tuple <int, SimulationType>(item1: Convert.ToInt32(value: paramsList[index: 6]), item2: (paramsList[index: 7] == "Central") ? SimulationType.Central : SimulationType.Decentral));
            }
            if (paramsList.Count() >= 6)
            {
                _simList.Add(item: new Tuple <int, SimulationType>(item1: Convert.ToInt32(value: paramsList[index: 4]), item2: (paramsList[index: 5] == "Central") ? SimulationType.Central : SimulationType.Decentral));
            }
            if (paramsList.Count() >= 4)
            {
                _simList.Add(item: new Tuple <int, SimulationType>(item1: Convert.ToInt32(value: paramsList[index: 2]), item2: (paramsList[index: 3] == "Central") ? SimulationType.Central : SimulationType.Decentral));
            }

            var kpi = new List <Kpi>();

            // charttype
            foreach (var sim in _simList)
            {
                var trick17 = _context.Kpis.Where(predicate: x => x.KpiType == KpiType.LeadTime &&
                                                  x.SimulationConfigurationId == sim.Item1 &&
                                                  x.SimulationNumber == 1 &&
                                                  x.SimulationType == sim.Item2);
                kpi.AddRange(collection: trick17.ToList());
            }

            var max = kpi.Max(selector: m => m.Value);

            var generateChartTask = Task.Run(function: () =>
            {
                if (!_context.SimulationOperations.Any())
                {
                    return(null);
                }


                Chart chart = new Chart();

                // charttype
                chart.Type = Enums.ChartType.Bar;

                // use available hight in Chart
                chart.Options = new Options()
                {
                    MaintainAspectRatio = false,
                    Responsive          = true,
                    Legend = new Legend {
                        Position = "bottom", Display = false
                    },
                    Title = new Title {
                        Text = "BoxPlot LeadTimes", Position = "top", FontSize = 24, FontStyle = "bold", Display = true
                    },
                    Scales = new Scales {
                        YAxes = new List <Scale> {
                            new CartesianScale {
                                Stacked = true, Display = true, Ticks = new CartesianLinearTick {
                                    Max = ((int)Math.Ceiling(a: max / 100.0)) * 100
                                }
                            }
                        },
                        XAxes = new List <Scale> {
                            new CartesianScale {
                                Stacked = true, Display = true
                            }
                        },
                    },
                    Tooltips = new ToolTip {
                        Mode = "x", Callbacks = new Callback {
                            Label = BoxplotCallback()
                        }
                    }
                };

                var labels = kpi.Select(selector: n => n.Name).Distinct().ToList();

                var data = new Data
                {
                    Datasets = new List <Dataset>(),
                    Labels   = labels,
                };
                var dsClear = new BarDataset {
                    Data = new List <double>(), Label = "dsClear", BackgroundColor = new List <ChartColor>(), BorderWidth = new List <int>(), BorderColor = new List <ChartColor>()
                };
                var lowerStroke = new BarDataset {
                    Data = new List <double>(), Label = "lowerStroke", BackgroundColor = new List <ChartColor>(), BorderWidth = new List <int>(), BorderColor = new List <ChartColor>()
                };
                var firstQuartile = new BarDataset {
                    Data = new List <double>(), Label = "fQ", BackgroundColor = new List <ChartColor>(), BorderWidth = new List <int>(), BorderColor = new List <ChartColor>()
                };
                var secondQuartile = new BarDataset {
                    Data = new List <double>(), Label = "Med", BackgroundColor = new List <ChartColor>(), BorderWidth = new List <int>(), BorderColor = new List <ChartColor>()
                };
                var thirdQuartile = new BarDataset {
                    Data = new List <double>(), Label = "uQ", BackgroundColor = new List <ChartColor>(), BorderWidth = new List <int>(), BorderColor = new List <ChartColor>()
                };
                var fourthQuartile = new BarDataset {
                    Data = new List <double>(), Label = "line", BackgroundColor = new List <ChartColor>(), BorderWidth = new List <int>(), BorderColor = new List <ChartColor>()
                };
                var upperStroke = new BarDataset {
                    Data = new List <double>(), Label = "upperStroke", BackgroundColor = new List <ChartColor>(), BorderWidth = new List <int>(), BorderColor = new List <ChartColor>()
                };


                var products = kpi.Select(selector: x => x.Name).Distinct().ToList();
                var colors   = new ChartColors();
                int i        = 0;

                foreach (var sim in _simList)
                {
                    foreach (var product in products)
                    {
                        var boxplotValues = kpi.Where(predicate: x => x.IsKpi == false && x.Name == product &&
                                                      x.SimulationConfigurationId == sim.Item1 &&
                                                      x.SimulationType == sim.Item2).OrderBy(keySelector: x => x.Value)
                                            .ToList();

                        dsClear.Data.Add(item: (double)boxplotValues.ElementAt(index: 0).Value);
                        dsClear.BackgroundColor.Add(item: ChartColors.Transparent);
                        dsClear.BorderColor.Add(item: ChartColors.Transparent);
                        dsClear.BorderWidth.Add(item: 0);

                        lowerStroke.Data.Add(item: 5);
                        lowerStroke.BackgroundColor.Add(item: ChartColors.Transparent);
                        lowerStroke.BorderColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1));
                        lowerStroke.BorderWidth.Add(item: 2);

                        var fq = (double)(boxplotValues.ElementAt(index: 1).Value - boxplotValues.ElementAt(index: 0).Value - 5);
                        firstQuartile.Data.Add(item: fq);
                        firstQuartile.BackgroundColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1));// .Add(colors.Color[i].Substring(0, colors.Color[i].Length - 4) + "0.8)");
                        firstQuartile.BorderColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1));
                        firstQuartile.BorderWidth.Add(item: 0);

                        var m = (double)(boxplotValues.ElementAt(index: 2).Value - boxplotValues.ElementAt(index: 1).Value);
                        secondQuartile.Data.Add(item: m);
                        secondQuartile.BackgroundColor.Add(item: colors.Get(i, 0.8));
                        secondQuartile.BorderColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1));
                        secondQuartile.BorderWidth.Add(item: 1);

                        var up = (double)(boxplotValues.ElementAt(index: 3).Value - boxplotValues.ElementAt(index: 2).Value);
                        thirdQuartile.Data.Add(item: up);
                        thirdQuartile.BackgroundColor.Add(item: colors.Get(i, 0.8));
                        thirdQuartile.BorderColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1));
                        thirdQuartile.BorderWidth.Add(item: 1);

                        var hs = (double)(boxplotValues.ElementAt(index: 4).Value - boxplotValues.ElementAt(index: 3).Value - 5);
                        fourthQuartile.Data.Add(item: hs);
                        fourthQuartile.BackgroundColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1)); //.Add(colors.Color[i].Substring(0, colors.Color[i].Length - 4) +  "0.8)");
                        fourthQuartile.BorderColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1));
                        fourthQuartile.BorderWidth.Add(item: 0);

                        upperStroke.Data.Add(item: 5);
                        upperStroke.BackgroundColor.Add(item: ChartColors.Transparent);
                        upperStroke.BorderColor.Add(item: ChartColor.FromRgba(50, 50, 50, 1));
                        upperStroke.BorderWidth.Add(item: 2);
                        i = i + 2;
                    }
                }


                data.Datasets.Add(item: dsClear);
                data.Datasets.Add(item: lowerStroke);
                data.Datasets.Add(item: firstQuartile);
                data.Datasets.Add(item: secondQuartile);
                data.Datasets.Add(item: thirdQuartile);
                data.Datasets.Add(item: fourthQuartile);
                data.Datasets.Add(item: upperStroke);

                var avg = kpi.Sum(selector: x => x.Value) / kpi.Count();
                var min = kpi.Min(selector: x => x.Value);
                var end = ((int)Math.Ceiling(a: max / 100.0)) * 100;


                //data.Datasets[0].Data = new List<double> { 0, (int)(min/end*100), (int)(avg /end*100), (int)(max /end*100), end };
                //data.Datasets[0].Data = new List<double> { min, avg, 10, max, end-max };

                chart.Data = data;
                return(chart);
            });

            // create JS to Render Chart.
            ViewData[index : "chart"]      = await generateChartTask;
            ViewData[index : "Type"]       = paramsList[index : 1];
            ViewData[index : "Data"]       = kpi.Where(predicate : w => w.IsFinal && w.IsKpi).ToList();
            ViewData[index : "percentage"] = Math.Round(value : kpi.Sum(selector : x => x.Value) / kpi.Count(), digits : 0);
            return(View(viewName: $"ProductLeadTime"));
        }
Ejemplo n.º 20
0
 public static ChartColor GetGrey()
 {
     return(ChartColor.FromRgba(201, 203, 207, 0.2));
 }
        private Chart GetGoalChart(StatisticsViewModel statisticsViewModel)
        {
            Chart chart = new Chart();
            Data  data  = new Data();

            data.Datasets = new List <Dataset>();
            chart.Data    = data;
            chart.Type    = Enums.ChartType.Line;


            data.Labels = new List <string>()
            {
                "asd", "asd", "asd", "asd", "asd", "asd", "asd"
            };
            LineDataset dataset = new LineDataset()
            {
                Label = "TestChart",
                Data  = new List <double?> {
                    65, 59, 80, 81, 56, 55, 40
                },
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

            data.Datasets.Add(dataset);
            return(chart);
        }
Ejemplo n.º 22
0
 public static ChartColor GetGreen()
 {
     return(ChartColor.FromRgba(75, 192, 192, 0.2));
 }
Ejemplo n.º 23
0
        public Chart GenerateNumberOfCoursesBarChart()
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Bar;

            Data          data    = new Data();
            List <Course> courses = _courseManager.GetAll().ToList();

            List <string> course = new List <string>()
            {
                "Courses"
            };

            data.Labels = course;

            List <double> numberOfCourses = new List <double>();

            numberOfCourses.Add(courses.Count());


            BarDataset dataset = new BarDataset()
            {
                Label           = "# of Courses",
                Data            = numberOfCourses,
                BackgroundColor = new List <ChartColor>
                {
                    ChartColor.FromRgba(255, 99, 132, 0.2),
                    ChartColor.FromRgba(54, 162, 235, 0.2),
                    ChartColor.FromRgba(255, 206, 86, 0.2),
                    ChartColor.FromRgba(75, 192, 192, 0.2),
                    ChartColor.FromRgba(153, 102, 255, 0.2),
                    ChartColor.FromRgba(255, 159, 64, 0.2)
                },
                BorderColor = new List <ChartColor>
                {
                    ChartColor.FromRgb(255, 99, 132),
                    ChartColor.FromRgb(54, 162, 235),
                    ChartColor.FromRgb(255, 206, 86),
                    ChartColor.FromRgb(75, 192, 192),
                    ChartColor.FromRgb(153, 102, 255),
                    ChartColor.FromRgb(255, 159, 64)
                },
                BorderWidth = new List <int>()
                {
                    1
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            chart.Data = data;

            var options = new Options
            {
                Scales = new Scales()
            };

            var scales = new Scales
            {
                YAxes = new List <Scale>
                {
                    new CartesianScale
                    {
                        Ticks = new CartesianLinearTick
                        {
                            BeginAtZero = true
                        }
                    }
                },
                XAxes = new List <Scale>
                {
                    new BarScale
                    {
                        BarPercentage   = 0.5,
                        BarThickness    = 6,
                        MaxBarThickness = 8,
                        MinBarLength    = 2,
                        GridLines       = new GridLine()
                        {
                            OffsetGridLines = true
                        }
                    }
                }
            };

            options.Scales = scales;

            chart.Options = options;

            chart.Options.Layout = new Layout
            {
                Padding = new Padding
                {
                    PaddingObject = new PaddingObject
                    {
                        Left  = 10,
                        Right = 12
                    }
                }
            };

            return(chart);
        }
Ejemplo n.º 24
0
 public static ChartColor GetBlue()
 {
     return(ChartColor.FromRgba(54, 162, 235, 0.2));
 }
Ejemplo n.º 25
0
        async Task RefreshUI(SourceHistory history)
        {
            var labels = history.HistoryData
                         .Select(d => d.TimeStampUtc.LocalDateTime.ToString("HH:mm"))
                         .Reverse()
                         .ToArray();

            var dataHousePower = history.HistoryData
                                 .Select(d => {
                string value = d.DataItems[1].Value.ToString();
                double.TryParse(value, out double power);
                return(power);
            })
                                 .Reverse()
                                 .ToList();

            var dataSolarPower = history.HistoryData
                                 .Select(d => {
                string value = d.DataItems[2].Value.ToString();
                double.TryParse(value, out double power);
                return(power);
            })
                                 .Reverse()
                                 .ToList();

            var productionEnergy  = $"PV ({dataSolarPower.Last():0.#}kW)";
            var consumptionEnergy = $"Verbrauch ({dataHousePower.Last():0.#}kW)";

            var dataSetHousePower = new LineChartDataset <double>
            {
                Label           = consumptionEnergy,
                Data            = dataHousePower,
                BackgroundColor = new List <string> {
                    ChartColor.FromRgba(249, 134, 134, 0.5f)
                },
                BorderColor = new List <string> {
                    ChartColor.FromRgba(249, 134, 134, 1f)
                },
                Fill        = true,
                PointRadius = 2,
                BorderDash  = new List <int> {
                }
            };

            var dataSetSolarPower = new LineChartDataset <double>
            {
                Label           = productionEnergy,
                Data            = dataSolarPower,
                Fill            = true,
                BackgroundColor = new List <string> {
                    ChartColor.FromRgba(226, 228, 242, 0.8f)
                },
                BorderColor = new List <string> {
                    ChartColor.FromRgba(95, 104, 188, 0.5f)
                },
                PointRadius = 2,
                BorderDash  = new List <int> {
                }
            };


            await lineChart.Clear();

            await lineChart.AddLabel(labels);

            await lineChart.AddDataSet(dataSetHousePower);

            await lineChart.AddDataSet(dataSetSolarPower);

            await lineChart.Update();
        }
Ejemplo n.º 26
0
        private static Chart GenerateBarChartForYearOnYear(List <Project> listOfProjects)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Bar;
            Data data = new Data();

            List <List <Project> > result = listOfProjects
                                            .GroupBy(p => p.ArticleDate.Year)
                                            .Select(g => g.ToList())
                                            .ToList();


            List <string> datalabels = new List <string>();
            Dictionary <string, List <Project> > yearMap    = new Dictionary <string, List <Project> >();
            Dictionary <string, double>          counterMap = new Dictionary <string, double>();

            foreach (var projectListByYear in result)
            {
                datalabels.Add(projectListByYear[0].ArticleDate.Year.ToString());
                yearMap.Add(projectListByYear[0].ArticleDate.Year.ToString(), projectListByYear);
                counterMap.Add(projectListByYear[0].ArticleDate.Year.ToString(), (double)projectListByYear.Count);
            }



            List <double> countList = new List <double>();

            data.Labels = datalabels;


            foreach (var year in data.Labels)
            {
                if (counterMap.TryGetValue(year, out double indResult))
                {
                    countList.Add(indResult);
                }
            }

            //Maybe this foreach and the one above could be merged?
            List <ChartColor> listOfBackgroundColors = new List <ChartColor>();
            List <ChartColor> listOfBorderColors     = new List <ChartColor>();
            Random            r = new Random();

            foreach (var year in data.Labels)
            {
                listOfBackgroundColors.Add(ChartColor.FromRgba((byte)r.Next(1, 255), (byte)r.Next(1, 255), (byte)r.Next(1, 255), 0.2));
                listOfBorderColors.Add(ChartColor.FromRgb(listOfBackgroundColors.Last().Red, listOfBackgroundColors.Last().Green, listOfBackgroundColors.Last().Blue));
            }


            BarDataset dataset = new BarDataset()
            {
                Label           = "# of projects per year",
                Data            = countList,
                BackgroundColor = listOfBackgroundColors,
                BorderColor     = listOfBorderColors,
                BorderWidth     = new List <int>()
                {
                    1
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            chart.Data = data;

            var options = new Options
            {
                Scales = new Scales()
            };

            var scales = new Scales
            {
                YAxes = new List <Scale>
                {
                    new CartesianScale
                    {
                        Ticks = new CartesianLinearTick
                        {
                            BeginAtZero = true
                        }
                    }
                },
                XAxes = new List <Scale>
                {
                    new BarScale
                    {
                        BarPercentage   = 0.5,
                        BarThickness    = 6,
                        MaxBarThickness = 8,
                        MinBarLength    = 2,
                        GridLines       = new GridLine()
                        {
                            OffsetGridLines = true
                        }
                    }
                }
            };

            options.Scales = scales;

            chart.Options = options;

            chart.Options.Layout = new Layout
            {
                Padding = new Padding
                {
                    PaddingObject = new PaddingObject
                    {
                        Left  = 10,
                        Right = 12
                    }
                }
            };

            return(chart);
        }
Ejemplo n.º 27
0
        private static Chart GenerateBarChart()
        {
            var chart = new Chart {
                Type = Enums.ChartType.Bar
            };

            var data = new Data
            {
                Labels = new List <string>
                {
                    "Red",
                    "Blue",
                    "Yellow",
                    "Green",
                    "Purple",
                    "Orange"
                }
            };

            var dataset = new BarDataset
            {
                Label = "# of Votes",
                Data  = new List <double> {
                    12, 19, 3, 5, 2, 3
                },
                BackgroundColor = new List <ChartColor>
                {
                    ChartColor.FromRgba(255, 99, 132, 0.2),
                    ChartColor.FromRgba(54, 162, 235, 0.2),
                    ChartColor.FromRgba(255, 206, 86, 0.2),
                    ChartColor.FromRgba(75, 192, 192, 0.2),
                    ChartColor.FromRgba(153, 102, 255, 0.2),
                    ChartColor.FromRgba(255, 159, 64, 0.2)
                },
                BorderColor = new List <ChartColor>
                {
                    ChartColor.FromRgb(255, 99, 132),
                    ChartColor.FromRgb(54, 162, 235),
                    ChartColor.FromRgb(255, 206, 86),
                    ChartColor.FromRgb(75, 192, 192),
                    ChartColor.FromRgb(153, 102, 255),
                    ChartColor.FromRgb(255, 159, 64)
                },
                BorderWidth = new List <int> {
                    1
                }
            };

            data.Datasets = new List <Dataset> {
                dataset
            };

            chart.Data = data;

            var options = new BarOptions
            {
                Scales        = new Scales(),
                BarPercentage = 0.7
            };

            var scales = new Scales
            {
                YAxes = new List <Scale>
                {
                    new CartesianScale
                    {
                        Ticks = new CartesianLinearTick
                        {
                            BeginAtZero = true
                        }
                    }
                }
            };

            options.Scales = scales;

            chart.Options = options;

            chart.Options.Layout = new Layout
            {
                Padding = new Padding
                {
                    PaddingObject = new PaddingObject
                    {
                        Left  = 10,
                        Right = 12
                    }
                }
            };

            return(chart);
        }
Ejemplo n.º 28
0
        private static Chart GenerateRadarChart(List <Project> listOfProjects)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Radar;

            Data data = new Data();

            data.Labels = new List <string>()
            {
                "Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"
            };

            RadarDataset dataset1 = new RadarDataset()
            {
                Label                = "My First dataset",
                BackgroundColor      = ChartColor.FromRgba(179, 181, 198, 0.2),
                BorderColor          = ChartColor.FromRgba(179, 181, 198, 1),
                PointBackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromRgba(179, 181, 198, 1)
                },
                PointBorderColor = new List <ChartColor>()
                {
                    ChartColor.FromHexString("#fff")
                },
                PointHoverBackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromHexString("#fff")
                },
                PointHoverBorderColor = new List <ChartColor>()
                {
                    ChartColor.FromRgba(179, 181, 198, 1)
                },
                Data = new List <double>()
                {
                    65, 59, 80, 81, 56, 55, 40
                }
            };

            RadarDataset dataset2 = new RadarDataset()
            {
                Label                = "My Second dataset",
                BackgroundColor      = ChartColor.FromRgba(255, 99, 132, 0.2),
                BorderColor          = ChartColor.FromRgba(255, 99, 132, 1),
                PointBackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromRgba(255, 99, 132, 1)
                },
                PointBorderColor = new List <ChartColor>()
                {
                    ChartColor.FromHexString("#fff")
                },
                PointHoverBackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromHexString("#fff")
                },
                PointHoverBorderColor = new List <ChartColor>()
                {
                    ChartColor.FromRgba(255, 99, 132, 1)
                },
                Data = new List <double>()
                {
                    28, 48, 40, 19, 96, 27, 100
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset1);
            data.Datasets.Add(dataset2);

            chart.Data = data;

            return(chart);
        }
        private const decimal SLICE_SHADE_STEP = 0.2023809523809524m;//https://stackoverflow.com/a/40619637

        private ChartColor SliceColorGenerator(int index) =>
        ChartColor.FromRgba(
            (byte)((index + 1) * 26 * SLICE_SHADE_STEP),
            (byte)((index + 1) * 35 * SLICE_SHADE_STEP),
            (byte)((index + 1) * 126 * SLICE_SHADE_STEP),
            1);
        private Chart GenerateUserChart()
        {
            var chart = new Chart
            {
                Type = Enums.ChartType.Bar
            };

            var data = new ChartJSCore.Models.Data
            {
                Labels = new List <string>()
                {
                    "Juni",
                    "Juli",
                    "Augustus",
                    "September",
                    "Oktober",
                    "November",
                    "December",
                    "Januari",
                    "Februari",
                    "Maart",
                    "April",
                    "Mei"
                }
            };

            var datasetSiteUsers = new BarDataset()
            {
                Label           = "Nieuwe gebruikers zonder Discord",
                Data            = new List <double?>(),
                BackgroundColor = new List <ChartColor>
                {
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                    ChartColor.FromRgba(0, 159, 227, 0.9),
                },
                BorderColor = new List <ChartColor>
                {
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227),
                    ChartColor.FromRgb(0, 159, 227)
                },
            };

            var datasetDiscordUsers = new BarDataset()
            {
                Label           = "Nieuwe gebruikers met Discord",
                Data            = new List <double?>(),
                BackgroundColor = new List <ChartColor>
                {
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9),
                    ChartColor.FromRgba(230, 0, 126, 0.9)
                },
                BorderColor = new List <ChartColor>
                {
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126),
                    ChartColor.FromRgb(230, 0, 126)
                },
            };

            for (int i = 0; i < 12; i++)
            {
                var time  = DateTime.Today.AddMonths(-i);
                var users = userRepository.GetAll()
                            .Where(u => u.CreationDate.Month == time.Month)
                            .ToList();
                datasetSiteUsers.Data.Add(users.Count(u => u.DiscordUserName is null));
                datasetDiscordUsers.Data.Add(users.Count(u => u.DiscordUserName is not null));
            }

            data.Datasets = new List <Dataset> {
                datasetSiteUsers, datasetDiscordUsers
            };

            chart.Data = data;

            return(chart);
        }