update grafico come stepped line

This commit is contained in:
Samuele E. Locatelli
2021-05-22 17:27:58 +02:00
parent a961542d40
commit 9880ef3d75
3 changed files with 33 additions and 9 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<div class="row">
<div class="col-2 pr-0">
<ul class="list-group list-group-sm small">
@foreach (var item in @CurrData)
@foreach (var item in @ParetoData)
{
<li class="list-group-item p-1 d-flex justify-content-between align-items-center">
@item.label
+15 -8
View File
@@ -127,7 +127,8 @@ namespace MP.Stats.Components
AspectRatio = 2.5
};
protected List<ChartKV> CurrData { get; set; } = new List<ChartKV>();
protected List<ChartKV> ParetoData { get; set; } = new List<ChartKV>();
protected List<ChartTS> TSData { get; set; } = new List<ChartTS>();
//protected override async Task OnAfterRenderAsync(bool firstRender)
//{
@@ -152,12 +153,12 @@ namespace MP.Stats.Components
List<string> GetBarChartLabels()
{
var answ = CurrData.Select(x => x.label).ToList();
var answ = ParetoData.Select(x => x.label).ToList();
return answ;
}
List<string> GetLineChartLabels()
{
var answ = CurrData.Select(x => x.label).ToList();
var answ = TSData.Select(x => x.TLabel.ToString()).ToList();
return answ;
}
@@ -166,8 +167,8 @@ namespace MP.Stats.Components
var answ = new BarChartDataset<double>
{
Label = "Pareto Causali Scarto",
Data = CurrData.Select(x => x.value).ToList(),
BackgroundColor = backgroundColors(CurrData.Count),
Data = ParetoData.Select(x => x.value).ToList(),
BackgroundColor = backgroundColors(ParetoData.Count),
//BorderColor = borderColors,
HoverBorderWidth = 5
};
@@ -178,10 +179,11 @@ namespace MP.Stats.Components
var answ = new LineChartDataset<double>
{
Label = "Numero Scarti Periodo",
Data = CurrData.Select(x => x.value).ToList(),
BackgroundColor = backgroundColors(CurrData.Count),
Data = TSData.Select(x => x.Value).ToList(),
BackgroundColor = backgroundColors(1),
Fill = true,
PointRadius = 2,
SteppedLine=true,
BorderDash = new List<int> { }
};
return answ;
@@ -217,11 +219,16 @@ namespace MP.Stats.Components
{
if (ListScarti != null)
{
CurrData = ListScarti
ParetoData = ListScarti
.GroupBy(x => x.Causale)
.Select(y => new ChartKV() { label = y.First().Descrizione, value = y.Sum(c => c.Qta) })
.OrderByDescending(x => x.value)
.ToList();
TSData = ListScarti
.Select(y => new ChartTS() { TLabel = y.DataOraRif, Value = y.Qta })
.OrderBy(x => x.TLabel)
.ToList();
}
}
}
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Stats.Data
{
public class ChartTS
{
#region Public Properties
public DateTime TLabel { get; set; } = DateTime.Now;
public double Value { get; set; } = 0;
#endregion Public Properties
}
}