public async Task <IViewComponentResult> InvokeAsync(string machine) { var generateChartTask = Task.Run(function: () => { if (!_context.SimulationJobs.Any()) { return(null); } Chart chart = new Chart(); // charttype chart.Type = Enums.ChartType.Pie; // use available hight in Chart chart.Options = new Options { MaintainAspectRatio = true }; var data = new Data(); // create Dataset for each Lable data.Datasets = new List <Dataset>(); var endSum = _context.SimulationJobs.Where(predicate: x => x.CapabilityProvider == machine).Sum(selector: x => x.End); var startSum = _context.SimulationJobs.Where(predicate: x => x.CapabilityProvider == machine).Sum(selector: x => x.Start); var max = _context.SimulationJobs.Max(selector: x => x.End); var work = endSum - startSum; var wait = max - work; var cc = new ChartColors(); data.Datasets.Add(item: new PieDataset { Data = new List <double?> { work, wait }, BackgroundColor = new List <ChartColor> { cc.Get(2), cc.Get(0) } }); data.Labels = new string[] { "Work " + Math.Round(d: Convert.ToDecimal(value: work) / max * 100, decimals: 2) + " %", "Wait " + Math.Round(d: Convert.ToDecimal(value: wait) / max * 100, decimals: 2) + " %" }; chart.Data = data; chart.Options = new Options() { MaintainAspectRatio = false, Responsive = true }; return(chart); }); // create JS to Render Chart. ViewData[index : "chart"] = await generateChartTask; ViewData[index : "machine"] = machine; return(View(viewName: $"MachineWorkload")); }
private Task <Chart> GenerateChartTask(List <string> paramsList) { var generateChartTask = Task.Run(function: () => { if (!_resultContext.SimulationJobs.Any()) { return(null); } SimulationType simType = (paramsList[index: 1].Equals(value: "Decentral")) ? SimulationType.Decentral : SimulationType.Central; Chart chart = new Chart { Type = Enums.ChartType.Bar }; // charttype // use available hight in Chart // use available hight in Chart var machines = _resultContext.Kpis.Where(predicate: x => x.SimulationConfigurationId == Convert.ToInt32(paramsList[0]) && x.SimulationType == simType && x.KpiType == KpiType.ResourceUtilization && x.IsKpi && x.IsFinal && x.SimulationNumber == Convert.ToInt32(paramsList[2])) .OrderByDescending(keySelector: g => g.Name) .ToList(); var data = new Data { Labels = machines.Select(selector: n => n.Name).ToList() }; // create Dataset for each Lable data.Datasets = new List <Dataset>(); var i = 0; var cc = new ChartColors(); //var max = _context.SimulationWorkschedules.Max(x => x.End) - 1440; var barDataSet = new BarDataset { Data = new List <double?>(), BackgroundColor = new List <ChartColor>(), HoverBackgroundColor = new List <ChartColor>(), YAxisID = "y-normal" }; var barDiversityInvisSet = new BarDataset { Data = new List <double?>(), BackgroundColor = new List <ChartColor>(), HoverBackgroundColor = new List <ChartColor>(), YAxisID = "y-diversity" }; var barDiversitySet = new BarDataset { Data = new List <double?>(), BackgroundColor = new List <ChartColor>(), HoverBackgroundColor = new List <ChartColor>(), YAxisID = "y-diversity" }; foreach (var machine in machines) { var percent = Math.Round(value: machine.Value * 100, digits: 2); // var wait = max - work; barDataSet.Data.Add(item: percent); barDataSet.BackgroundColor.Add(item: cc.Get(i, 0.4)); barDataSet.HoverBackgroundColor.Add(item: cc.Get(i, 0.7)); var varianz = machine.Count * 100; barDiversityInvisSet.Data.Add(item: percent - Math.Round(value: varianz / 2, digits: 2)); barDiversityInvisSet.BackgroundColor.Add(item: ChartColors.Transparent); barDiversityInvisSet.HoverBackgroundColor.Add(item: ChartColors.Transparent); barDiversitySet.Data.Add(item: Math.Round(value: varianz, digits: 2)); barDiversitySet.BackgroundColor.Add(item: cc.Get(i, 0.8)); barDiversitySet.HoverBackgroundColor.Add(item: cc.Get(i, 1)); i++; } data.Datasets.Add(item: barDataSet); data.Datasets.Add(item: barDiversityInvisSet); data.Datasets.Add(item: barDiversitySet); chart.Data = data; // Specifie xy Axis var xAxis = new List <Scale>() { new CartesianScale { Stacked = true, Id = "x-normal", Display = true } }; var yAxis = new List <Scale>() { new CartesianScale { Stacked = true, Display = true, Ticks = new CartesianLinearTick { BeginAtZero = true, Min = 0, Max = 100 }, Id = "y-normal" }, new CartesianScale { Stacked = true, Ticks = new CartesianLinearTick { BeginAtZero = true, Min = 0, Max = 100 }, Display = false, Id = "y-diversity", ScaleLabel = new ScaleLabel { LabelString = "Value in %", Display = false, FontSize = 12 }, }, }; //var yAxis = new List<Scale>() { new BarScale{ Ticks = new CategoryTick { Min = "0", Max = (yMaxScale * 1.1).ToString() } } }; chart.Options = new Options() { Scales = new Scales { XAxes = xAxis, YAxes = yAxis }, MaintainAspectRatio = false, Responsive = true, Title = new Title { Text = "Machine Workloads", Position = "top", FontSize = 24, FontStyle = "bold", Display = true }, Legend = new Legend { Position = "bottom", Display = false } }; return(chart); }); return(generateChartTask); }
private Task <Chart> GenerateChartTaskOverTime(List <string> paramsList) { var generateChartTask = Task.Run(function: () => { if (!_resultContext.SimulationJobs.Any()) { return(null); } SimulationType simType = (paramsList[index: 1].Equals(value: "Decentral")) ? SimulationType.Decentral : SimulationType.Central; Chart chart = new Chart { Type = Enums.ChartType.Scatter }; // charttype var cc = new ChartColors(); // use available hight in Chart // use available hight in Chart var machinesKpi = _resultContext.Kpis.Where(predicate: x => x.SimulationConfigurationId == Convert.ToInt32(paramsList[0]) && x.SimulationType == simType && x.KpiType == KpiType.ResourceUtilization && !x.IsKpi && !x.IsFinal && x.SimulationNumber == Convert.ToInt32(paramsList[2])) .ToList(); var settlingTime = _resultContext.SimulationConfigurations.First(predicate: x => x.Id == Convert.ToInt32(paramsList[0])).SettlingStart; var machines = machinesKpi.Select(selector: n => n.Name).Distinct().ToList(); var data = new Data { Labels = machines }; // create Dataset for each Lable data.Datasets = new List <Dataset>(); var i = 0; foreach (var machine in machines) { // add zero to start var kpis = new List <LineScatterData> { new LineScatterData { X = "0", Y = "0" } }; kpis.AddRange(collection: machinesKpi.Where(predicate: x => x.Name == machine).OrderBy(keySelector: x => x.Time) .Select(selector: x => new LineScatterData { X = x.Time.ToString(), Y = (x.Value * 100).ToString() }).ToList()); var lds = new LineScatterDataset() { Data = kpis, BorderWidth = 2, Label = machine, ShowLine = true, Fill = "false", BackgroundColor = cc.Get(i), BorderColor = cc.Get(i++), LineTension = 0 }; data.Datasets.Add(item: lds); } data.Datasets.Add(item: new LineScatterDataset() { Data = new List <LineScatterData> { new LineScatterData { X = "0", Y = "100" }, new LineScatterData { X = Convert.ToDouble(value: settlingTime).ToString(), Y = "100" } }, BorderWidth = 1, Label = "Settling time", BackgroundColor = ChartJSCore.Helpers.ChartColor.FromRgba(0, 0, 0, 0.1), BorderColor = ChartJSCore.Helpers.ChartColor.FromRgba(0, 0, 0, 0.3), ShowLine = true, //Fill = true, //SteppedLine = false, LineTension = 0, PointRadius = new List <int> { 0, 0 } }); chart.Data = data; // Specifie xy Axis var xAxis = new List <Scale>() { new CartesianScale { Stacked = false, Display = true } }; var yAxis = new List <Scale>() { new CartesianScale() { Stacked = false, Ticks = new CartesianLinearTick { BeginAtZero = true, Min = 0, Max = 100 }, Display = true, Id = "first-y-axis", Type = "linear", ScaleLabel = new ScaleLabel { LabelString = "Value in %", Display = true, FontSize = 12 }, } }; //var yAxis = new List<Scale>() { new BarScale{ Ticks = new CategoryTick { Min = "0", Max = (yMaxScale * 1.1).ToString() } } }; chart.Options = new Options() { Scales = new Scales { XAxes = xAxis, YAxes = yAxis }, Responsive = true, MaintainAspectRatio = true, Legend = new Legend { Position = "bottom", Display = true, FullWidth = true }, Title = new Title { Text = "Machine Workload over Time", Position = "top", FontSize = 24, FontStyle = "bold", Display = true } }; return(chart); }); return(generateChartTask); }
public async Task <IViewComponentResult> InvokeAsync(List <string> paramsList) { // Determine Type and Data SimulationType simType = (paramsList[index : 1].Equals(value : "Decentral")) ? SimulationType.Decentral : SimulationType.Central; var kpi = _context.Kpis.Where(predicate: x => x.KpiType == KpiType.Timeliness && x.SimulationConfigurationId == Convert.ToInt32(paramsList[0]) && x.SimulationNumber == Convert.ToInt32(paramsList[2]) && x.SimulationType == simType); var generateChartTask = Task.Run(function: () => { if (!_context.SimulationJobs.Any()) { return(null); } Chart chart = new Chart(); // charttype chart.Type = Enums.ChartType.Doughnut; // use available hight in Chart chart.Options = new PieOptions { MaintainAspectRatio = false, Responsive = true , CutoutPercentage = 80 , Rotation = 0.8 * Math.PI , Circumference = 1.4 * Math.PI , Legend = new Legend { Position = "bottom", Display = false } , Title = new Title { Text = "Timeliness", Position = "top", FontSize = 24, FontStyle = "bold" } }; var cc = new ChartColors(); var data = new Data { Datasets = new List <Dataset> { new PieDataset { BackgroundColor = new[] { cc.Get(4, 0.3), cc.Get(4, 0.3) }, BorderColor = new[] { cc.Get(4, 0.8), cc.Get(4, 0.8) }, BorderWidth = 1, } }, Labels = new[] { "Early", "Overdue" }, }; var avg = kpi.Sum(selector: x => x.Value) / kpi.Count() * 100; //var end = ((int)Math.Ceiling(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[index: 0].Data = new List <double?> { avg, 100 - avg }; chart.Data = data; return(chart); }); // create JS to Render Chart. ViewData[index : "chart"] = await generateChartTask; ViewData[index : "Type"] = paramsList[index : 1]; ViewData[index : "Percentage"] = Math.Round(value : kpi.Sum(selector : x => x.Value) / kpi.Count() * 100, digits : 0); ViewData[index : "Data"] = kpi.ToList(); return(View(viewName: $"OrderTimeliness")); }
private Task <Chart> GenerateChartTask(List <string> paramsList) { var generateChartTask = Task.Run(function: () => { if (!_context.SimulationOperations.Any()) { return(null); } Chart chart = new Chart { Type = Enums.ChartType.Bar, Options = new Options { MaintainAspectRatio = true } }; var machines = new List <Kpi>(); // charttype foreach (var sim in _simList) { var trick17 = _context.Kpis.Where(predicate: x => x.SimulationConfigurationId == sim.Item1 && x.KpiType == KpiType.MachineUtilization && x.IsKpi && x.SimulationType == sim.Item2 && x.SimulationNumber == 1 && x.IsFinal).OrderByDescending(keySelector: g => g.Name); machines.AddRange(collection: trick17.ToList()); } var data = new Data { Labels = machines.Select(selector: n => n.Name).Distinct().ToList() }; // create Dataset for each Lable data.Datasets = new List <Dataset>(); var i = 0; var cc = new ChartColors(); //var max = _context.SimulationWorkschedules.Max(x => x.End) - 1440; foreach (var t1 in _simList.OrderBy(keySelector: x => x.Item1)) { var barDataSet = new BarDataset { Data = new List <double>(), BackgroundColor = new List <ChartColor>(), HoverBackgroundColor = new List <ChartColor>(), YAxisID = "y-normal" }; var barDiversityInvisSet = new BarDataset { Data = new List <double>(), BackgroundColor = new List <ChartColor>(), HoverBackgroundColor = new List <ChartColor>(), YAxisID = "y-diversity" }; var barDiversitySet = new BarDataset { Data = new List <double>(), BackgroundColor = new List <ChartColor>(), HoverBackgroundColor = new List <ChartColor>(), YAxisID = "y-diversity" }; barDataSet.Label = "Sim Id:" + t1.Item1 + " " + t1.Item2; foreach (var machineName in data.Labels) { Kpi machine = null; var t = machines.Where(predicate: x => x.Name == machineName && x.SimulationConfigurationId == t1.Item1 && x.SimulationType == t1.Item2).Distinct(); machine = t.Single(); var percent = Math.Round(value: machine.Value * 100, digits: 2); // var wait = max - work; barDataSet.Data.Add(item: percent); barDiversitySet.BackgroundColor.Add(item: cc.Get(i, 0.4)); barDiversitySet.HoverBackgroundColor.Add(item: cc.Get(i, 0.7)); //var varianz = machine.Count * 100; //barDiversityInvisSet.Data.Add(percent - Math.Round(varianz / 2, 2)); //barDiversityInvisSet.BackgroundColor.Add(ChartColor.Transparent); //barDiversityInvisSet.HoverBackgroundColor.Add(ChartColor.Transparent); // //barDiversitySet.Data.Add(Math.Round(varianz, 2)); //barDiversitySet.BackgroundColor.Add(cc.Color[i].Substring(0, cc.Color[1].Length - 4) + (t + 0.3) + ")"); //barDiversitySet.HoverBackgroundColor.Add(cc.Color[i].Substring(0, cc.Color[1].Length - 4) + "1)"); } i++; i++; data.Datasets.Add(item: barDataSet); //data.Datasets.Add(barDiversityInvisSet); //data.Datasets.Add(barDiversitySet); } chart.Data = data; // Specifie xy Axis var xAxis = new List <Scale>() { new CartesianScale { Stacked = false, Id = "x-normal", Display = true } }; var yAxis = new List <Scale>() { new CartesianScale { Stacked = false, Display = true, Ticks = new CartesianLinearTick { BeginAtZero = true, Min = 0, Max = 100 }, Id = "y-normal" }, new CartesianScale { Stacked = false, Ticks = new CartesianLinearTick { BeginAtZero = true, Min = 0, Max = 100 }, Display = false, Id = "y-diversity", ScaleLabel = new ScaleLabel { LabelString = "Value in %", Display = false, FontSize = 12 }, }, }; //var yAxis = new List<Scale>() { new BarScale{ Ticks = new CategoryTick { Min = "0", Max = (yMaxScale * 1.1).ToString() } } }; chart.Options = new Options() { Scales = new Scales { XAxes = xAxis, YAxes = yAxis }, MaintainAspectRatio = false, Responsive = true, Legend = new Legend { Display = false } }; return(chart); }); return(generateChartTask); }
public async Task <IViewComponentResult> InvokeAsync(List <string> paramsList) { // Determine Type and Data // 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)); } _simList = _simList.OrderBy(keySelector: x => x.Item2).ThenBy(keySelector: x => x.Item1).ToList(); var displayData = new List <Kpi>(); 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 maxValue = kpi.Max(selector: x => x.Value); var generateChartTask = Task.Run(function: () => { if (!kpi.Any()) { return(null); } var chart = new List <BoxPlot>(); var products = kpi.Select(selector: x => x.Name).Distinct().ToList(); var colors = new ChartColors(); int i = 0; foreach (var sim in _simList) { displayData.AddRange(collection: kpi.Where(predicate: x => x.IsKpi && x.SimulationConfigurationId == sim.Item1 && x.SimulationType == sim.Item2).OrderBy(keySelector: x => x.Value).ToList()); foreach (var product in products) { var boxplotValues = kpi.Where(predicate: x => x.IsKpi == false && x.Name == product && x.KpiType == KpiType.LeadTime && x.SimulationConfigurationId == sim.Item1 && x.SimulationNumber == 1 && x.IsFinal && x.SimulationType == sim.Item2).OrderBy(keySelector: x => x.Value).ToList(); if (boxplotValues.Count == 0) { continue; } chart.Add(item: new BoxPlot { HeigestSample = (decimal)boxplotValues.ElementAt(index: 4).Value, UpperQartile = (decimal)boxplotValues.ElementAt(index: 3).Value, Median = (decimal)boxplotValues.ElementAt(index: 2).Value, LowerQuartile = (decimal)boxplotValues.ElementAt(index: 1).Value, LowestSample = (decimal)boxplotValues.ElementAt(index: 0).Value, Name = product + "<br> SimId:" + sim.Item1 + " " + sim.Item2, Color = colors.Get(i).ToString() }); if (_simList.Count() == 1) { i++; } } i = i + 2; } //new BoxPlot{ HeigestSample=337, UpperQartile=195, Median=163, LowerQuartile= 136, LowestSample = 73, Name="Race-Truck", Color = "rgba(0,102,255," } return(chart); }); // create JS to Render Chart. var boxPlot = await generateChartTask; ViewData[index : "BoxPlot"] = boxPlot; ViewData[index : "Type"] = paramsList[index : 1]; ViewData[index : "Data"] = displayData.Distinct().ToList(); ViewData[index : "Max"] = Math.Ceiling(a : maxValue / 100) * 100; //ViewData["Max"] = Math.Ceiling((double)boxPlot.Max(x => x.HeigestSample)/100)*100; return(View(viewName: $"ProductLeadTimeBoxPlot")); }
/// <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")); }