Fix grafico pareto guasti con componente standard!

This commit is contained in:
Samuele Locatelli
2022-02-25 20:19:34 +01:00
parent 349758a289
commit 557a9510d6
9 changed files with 50 additions and 88 deletions
+4 -4
View File
@@ -12,12 +12,12 @@
[Parameter]
public bool Horizontal { get; set; } = false;
[Parameter]
public List<double> Data { get; set; } = new List<double>();
[Parameter]
public string[]? Data { get; set; }
[Parameter]
public string[]? Labels { get; set; }
public List<string> Labels { get; set; } = new List<string>();
[Parameter]
public double AspRatio { get; set; } = 0;
+1 -1
View File
@@ -9,7 +9,7 @@
public string Id { get; set; } = "MyTs";
[Parameter]
public List<double> Data { get; set; } = null!;
public List<double> Data { get; set; } = new List<double>();
[Parameter]
public List<string> Labels { get; set; } = new List<string>();
+5 -2
View File
@@ -1,4 +1,7 @@
<div class="row">
@using MP.Stats.Components.ChartJs
<div class="row">
@if (RawData == null || RawData.Count == 0)
{
<div class="col-12">
@@ -21,7 +24,7 @@
<div class="col-10">
<div class="row">
<div class="col-6">
@*<BarChart @ref="ParetoGuasti" TItem="double" OptionsObject="barChartOptions" />*@
<BarPlot Id="ParetoOee" AspRatio="3" Data="@DatiGuasti" Labels="@LabelGuasti" Legenda="Pareto OEE Macchine" lineColor="@lineColors" backColor="@bgColors"></BarPlot>
</div>
<div class="col-6">
@*<LineChart @ref="NumGuasti" TItem="double" OptionsObject="lineChartOptions" />*@
+34 -75
View File
@@ -11,75 +11,7 @@ namespace MP.Stats.Components
{
#region Protected Fields
protected object barChartOptions = new
{
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
},
Animation = false,
AspectRatio = 3.5
};
protected object lineChartOptions = new
{
Scales = new
{
XAxes = new object[]
{
new {
Display = true,
//type = "time"
}
},
YAxes = new object[]
{
new {
Display = true,
ticks= new {
min = 0,
max = 100
}
}
}
},
Tooltips = new
{
Mode = "nearest",
Intersect = false
},
Hover = new
{
Mode = "nearest",
Intersect = false
},
Animation = false,
AspectRatio = 3.5
};
protected List<double> NumGuasti = new List<double>();
@@ -169,6 +101,15 @@ namespace MP.Stats.Components
}
#endif
private List<double> DatiGuasti
{
get => ParetoData.Select(x => x.value).ToList();
}
private List<string> LabelGuasti
{
get => ParetoData.Select(x => x.label).ToList();
}
private List<string> GetLineChartLabels()
{
var answ = TSData.Select(x => x.TLabel.ToString("ddd dd.MM")).ToList();
@@ -202,29 +143,47 @@ namespace MP.Stats.Components
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> backgroundColors(int numRecords, float alpha)
protected List<string> calcColors(int numRecords, double alpha)
{
List<string> answ = new List<string>();
#if false
// verde...
for (int i = 0; i < numRecords / 3; i++)
{
answ.Add(ChartColor.FromRgba(54, 235, 82, alpha));
answ.Add($"rgba(54, 235, 82, {alpha.ToString("N2").Replace(",", ".")})");
}
// arancione
for (int i = 0; i < numRecords / 3; i++)
{
answ.Add(ChartColor.FromRgba(255, 206, 86, alpha));
answ.Add($"rgba(255, 206, 86, {alpha.ToString("N2").Replace(",", ".")})");
}
while (answ.Count < numRecords)
{
answ.Add(ChartColor.FromRgba(255, 99, 132, alpha));
answ.Add($"rgba(255, 99, 132, {alpha.ToString("N2").Replace(",",".")}");
}
#endif
return answ;
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColors
{
get => calcColors(ParetoData.Count, 1);
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> bgColors
{
get => calcColors(ParetoData.Count, 0.3);
}
protected async Task HandleRedraw()
{
if (ParetoGuasti != null)
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Stats</RootNamespace>
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
<Version>6.14.2202.2519</Version>
<Version>6.14.2202.2520</Version>
</PropertyGroup>
<ItemGroup>
+2 -2
View File
@@ -36,13 +36,13 @@
<div class="row">
<div class="col-6">
<BarPlot Id="TestBar" AspRatio="3" Data="@histGroupData" Labels="@histGroupLabel" lineColor="@lineColors" backColor="@bgColors" Legenda="Freq. Osservate"></BarPlot>
<BarPlot Id="TestBar" AspRatio="3" Data="@histData" Labels="@histLabel" lineColor="@lineColors" backColor="@bgColors" Legenda="Freq. Osservate"></BarPlot>
</div>
<div class="col-6">
<StepLine Id="TestTS" AspRatio="3" DataTS="@dataList" lineColor="@lineColors.Skip(4).Take(1).ToList()" backColor="@bgColors.Skip(4).Take(1).ToList()"></StepLine>
</div>
<div class="col-6">
<BarPlot Id="TestBarHor" Horizontal="true" AspRatio="3" Data="@histGroupData" Labels="@histGroupLabel" lineColor="@lineColors" backColor="@bgColors" Legenda="Freq. Osservate"></BarPlot>
<BarPlot Id="TestBarHor" Horizontal="true" AspRatio="3" Data="@histData" Labels="@histLabel" lineColor="@lineColors" backColor="@bgColors" Legenda="Freq. Osservate"></BarPlot>
</div>
<div class="col-6">
<Line Id="TestLineTS" AspRatio="3" DataTS="@dataList" lineColor="@lineColors.Skip(1).Take(1).ToList()" backColor="@bgColors.Skip(1).Take(1).ToList()" lTens="@lineTens"></Line>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo statistiche MAPO</i>
<h4>Versione: 6.14.2202.2519</h4>
<h4>Versione: 6.14.2202.2520</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.14.2202.2519
6.14.2202.2520
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.14.2202.2519</version>
<version>6.14.2202.2520</version>
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>