Abbozzato grafico a linea

This commit is contained in:
Samuele E. Locatelli
2021-05-22 17:04:48 +02:00
parent 04c6d0a317
commit a961542d40
2 changed files with 89 additions and 20 deletions
+17 -15
View File
@@ -1,24 +1,26 @@
@using MP.Stats.Data
<div class="row">
<div class="col-6">
<div class="col-2 pr-0">
<ul class="list-group list-group-sm small">
@foreach (var item in @CurrData)
{
<li class="list-group-item p-1 d-flex justify-content-between align-items-center">
@item.label
<span class="badge badge-primary badge-pill">@item.value</span>
</li>
}
</ul>
</div>
<div class="col-10">
<div class="row">
<div class="col-3 pr-0">
<ul class="list-group list-group-sm small">
@foreach (var item in @CurrData)
{
<li class="list-group-item p-1 d-flex justify-content-between align-items-center">
@item.label
<span class="badge badge-primary badge-pill">@item.value</span>
</li>
}
</ul>
</div>
<div class="col-9">
<div class="col-6">
<BarChart @ref="ParetoGuasti" TItem="double" OptionsObject="barChartOptions" />
</div>
<div class="col-6">
<LineChart @ref="NumGuasti" TItem="double" OptionsObject="lineChartOptions" />
</div>
</div>
</div>
<div class="col-6">
</div>
</div>
+72 -5
View File
@@ -37,8 +37,9 @@ namespace MP.Stats.Components
}
protected BarChart<double> ParetoGuasti;
protected LineChart<double> NumGuasti;
object barChartOptions = new
protected object barChartOptions = new
{
//Title = new
//{
@@ -48,20 +49,20 @@ namespace MP.Stats.Components
Scales = new
{
XAxes = new object[]
{
{
new {
Display = false
}
},
},
YAxes = new object[]
{
{
new {
Display = true,
ticks= new {
suggestedMin = 0
}
}
}
}
},
Tooltips = new
{
@@ -82,6 +83,49 @@ namespace MP.Stats.Components
AspectRatio = 2.5
};
protected object lineChartOptions = new
{
//Title = new
//{
// Display = true,
// Text = "Causali Scarto"
//},
Scales = new
{
XAxes = new object[]
{
new {
Display = false
}
},
YAxes = new object[]
{
new {
Display = true,
ticks= new {
suggestedMin = 0
}
}
}
},
Tooltips = new
{
Mode = "nearest",
Intersect = false
},
Hover = new
{
Mode = "nearest",
Intersect = false
},
//Legend = new
//{
// Display = true,
// FullWidth = true
//},
Animation = false,
AspectRatio = 2.5
};
protected List<ChartKV> CurrData { get; set; } = new List<ChartKV>();
@@ -99,6 +143,11 @@ namespace MP.Stats.Components
await ParetoGuasti.Clear();
await ParetoGuasti.AddLabelsDatasetsAndUpdate(GetBarChartLabels(), GetBarChartDataset());
}
if (NumGuasti != null)
{
await NumGuasti.Clear();
await NumGuasti.AddLabelsDatasetsAndUpdate(GetLineChartLabels(), GetLineChartDataset());
}
}
List<string> GetBarChartLabels()
@@ -106,6 +155,11 @@ namespace MP.Stats.Components
var answ = CurrData.Select(x => x.label).ToList();
return answ;
}
List<string> GetLineChartLabels()
{
var answ = CurrData.Select(x => x.label).ToList();
return answ;
}
BarChartDataset<double> GetBarChartDataset()
{
@@ -119,6 +173,19 @@ namespace MP.Stats.Components
};
return answ;
}
LineChartDataset<double> GetLineChartDataset()
{
var answ = new LineChartDataset<double>
{
Label = "Numero Scarti Periodo",
Data = CurrData.Select(x => x.value).ToList(),
BackgroundColor = backgroundColors(CurrData.Count),
Fill = true,
PointRadius = 2,
BorderDash = new List<int> { }
};
return answ;
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo