Bozza visualizzazione linee TRS
This commit is contained in:
@@ -8,18 +8,31 @@
|
||||
[Parameter]
|
||||
public string Id { get; set; } = "MyTs";
|
||||
|
||||
[Parameter]
|
||||
public string Title { get; set; } = "Demo Line";
|
||||
|
||||
[Parameter]
|
||||
public List<chartJsData.chartJsTSerie> DataTS { get; set; } = null!;
|
||||
|
||||
|
||||
[Parameter]
|
||||
public List<string> Labels { get; set; } = new List<string>();
|
||||
|
||||
[Parameter]
|
||||
public List<string> lineColor { get; set; } = new List<string>();
|
||||
|
||||
[Parameter]
|
||||
public List<string> backColor { get; set; } = new List<string>();
|
||||
|
||||
|
||||
[Parameter]
|
||||
public double AspRatio { get; set; } = 0;
|
||||
|
||||
|
||||
[Parameter]
|
||||
public string MinValue { get; set; } = "0";
|
||||
|
||||
[Parameter]
|
||||
public string MaxValue { get; set; } = "100";
|
||||
|
||||
[Parameter]
|
||||
public int lTens { get; set; } = 0;
|
||||
|
||||
@@ -35,10 +48,7 @@
|
||||
/// <returns></returns>
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
//if (!firstRender)
|
||||
//{
|
||||
await renderChart();
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -68,7 +78,9 @@
|
||||
ticks = new
|
||||
{
|
||||
maxTicksLimit = 10
|
||||
}
|
||||
},
|
||||
suggestedMin = MinValue,
|
||||
suggestedMax = MaxValue
|
||||
},
|
||||
xAxes = new
|
||||
{
|
||||
@@ -81,8 +93,9 @@
|
||||
},
|
||||
data = new
|
||||
{
|
||||
//labels = Labels.ToArray(),
|
||||
datasets = new[]
|
||||
{
|
||||
{
|
||||
new
|
||||
{
|
||||
data = DataTS,
|
||||
@@ -90,7 +103,7 @@
|
||||
backgroundColor= backColor,
|
||||
lineTension= lTens,
|
||||
stepped= false,
|
||||
label= "Temperatura Rilevata"
|
||||
label= Title
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
<div class="col-10">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<BarPlot Id="ParetoOee" AspRatio="3" Data="@DatiGuasti" Labels="@LabelGuasti" Legenda="Pareto OEE Macchine" lineColor="@lineColors" backColor="@bgColors"></BarPlot>
|
||||
<BarPlot Id="ParetoOee" AspRatio="3" Data="@DatiParetoOee" Labels="@LabelParetoOee" Legenda="Pareto OEE Macchine" lineColor="@lineColors" backColor="@bgColors"></BarPlot>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
@*<LineChart @ref="NumGuasti" TItem="double" OptionsObject="lineChartOptions" />*@
|
||||
<Line Id="AndamentoTrs" AspRatio="3" DataTS="@DatiTrs" Labels="@LabelTrs" lineColor="@lineColor" backColor="@lineColor" lTens="0" Title="Andamento TRS" MinValue="0" MaxValue="110"></Line>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Stats.Data;
|
||||
|
||||
namespace MP.Stats.Components
|
||||
@@ -11,7 +12,7 @@ namespace MP.Stats.Components
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
|
||||
|
||||
|
||||
protected List<double> NumGuasti = new List<double>();
|
||||
|
||||
@@ -33,7 +34,7 @@ namespace MP.Stats.Components
|
||||
[Inject]
|
||||
protected MpStatsService StatService { get; set; }
|
||||
|
||||
protected List<ChartTS> TSData { get; set; } = new List<ChartTS>();
|
||||
protected List<chartJsData.chartJsTSerie> TSData { get; set; } = new List<chartJsData.chartJsTSerie>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
@@ -51,10 +52,6 @@ namespace MP.Stats.Components
|
||||
{
|
||||
// ricalcolo charting data
|
||||
recalcData();
|
||||
var dataReload = Task.Run(async () =>
|
||||
{
|
||||
await HandleRedraw();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,59 +60,40 @@ namespace MP.Stats.Components
|
||||
|
||||
#region Private Methods
|
||||
|
||||
#if false
|
||||
private BarChartDataset<double> GetBarChartDataset()
|
||||
{
|
||||
var answ = new BarChartDataset<double>
|
||||
{
|
||||
Label = "Pareto OEE Macchine",
|
||||
Data = ParetoData.Select(x => x.value).ToList(),
|
||||
BackgroundColor = backgroundColors(ParetoData.Count, 0.4f),
|
||||
BorderColor = backgroundColors(ParetoData.Count, 1f),
|
||||
HoverBorderWidth = 5
|
||||
};
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
private List<string> GetBarChartLabels()
|
||||
{
|
||||
var answ = ParetoData.Select(x => x.label).ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
private LineChartDataset<double> GetLineChartDataset()
|
||||
{
|
||||
var answ = new LineChartDataset<double>
|
||||
{
|
||||
Label = "TRS/OEE Periodo",
|
||||
Data = TSData.Select(x => x.Value).ToList(),
|
||||
BorderColor = backgroundColors(1, 1f),
|
||||
Fill = true,
|
||||
PointRadius = 2,
|
||||
LineTension = 0,
|
||||
BorderDash = new List<int> { }
|
||||
};
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
private List<double> DatiGuasti
|
||||
private List<double> DatiParetoOee
|
||||
{
|
||||
get => ParetoData.Select(x => x.value).ToList();
|
||||
}
|
||||
private List<string> LabelGuasti
|
||||
private List<string> LabelParetoOee
|
||||
{
|
||||
get => ParetoData.Select(x => x.label).ToList();
|
||||
}
|
||||
|
||||
private List<string> GetLineChartLabels()
|
||||
private List<chartJsData.chartJsTSerie> DatiTrs
|
||||
{
|
||||
var answ = TSData.Select(x => x.TLabel.ToString("ddd dd.MM")).ToList();
|
||||
get => TSData;
|
||||
}
|
||||
private List<string> LabelTrs
|
||||
{
|
||||
get => TSData.Select(r => $"{r.x:dd.MM}").ToList();
|
||||
}
|
||||
|
||||
private Dictionary<DateTime, double> calcTSData(DateTime inizio, List<double> yData)
|
||||
{
|
||||
Dictionary<DateTime, double> answ = new Dictionary<DateTime, double>();
|
||||
// usando i dati ricevuti aggiunge variabile x = tempo crescente
|
||||
int idx = 0;
|
||||
foreach (var item in yData)
|
||||
{
|
||||
answ.Add(inizio.AddHours(idx), item);
|
||||
idx++;
|
||||
}
|
||||
// restituisco!
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
private void recalcData()
|
||||
{
|
||||
if (RawData != null)
|
||||
@@ -128,8 +106,8 @@ namespace MP.Stats.Components
|
||||
|
||||
TSData = RawData
|
||||
.GroupBy(x => x.DataRif.Date)
|
||||
.Select(y => new ChartTS() { TLabel = y.First().DataRif.Date, Value = Math.Round(y.Average(c => c.OEE) * 100, 2) })
|
||||
.OrderBy(x => x.TLabel)
|
||||
.Select(r => new chartJsData.chartJsTSerie() { x = r.First().DataRif.Date, y = Math.Round(r.Average(c => c.OEE) * 100, 2) })
|
||||
.OrderBy(o => o.x)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -143,27 +121,49 @@ namespace MP.Stats.Components
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> calcColors(int numRecords, double alpha)
|
||||
protected List<string> semaphColors(int numRecords, string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
// verde...
|
||||
for (int i = 0; i < numRecords / 3; i++)
|
||||
{
|
||||
answ.Add($"rgba(54, 235, 82, {alpha.ToString("N2").Replace(",", ".")})");
|
||||
answ.Add($"rgba(54, 235, 82, {alpha})");
|
||||
}
|
||||
// arancione
|
||||
for (int i = 0; i < numRecords / 3; i++)
|
||||
{
|
||||
answ.Add($"rgba(255, 206, 86, {alpha.ToString("N2").Replace(",", ".")})");
|
||||
answ.Add($"rgba(255, 206, 86, {alpha})");
|
||||
}
|
||||
while (answ.Count < numRecords)
|
||||
{
|
||||
answ.Add($"rgba(255, 99, 132, {alpha.ToString("N2").Replace(",",".")}");
|
||||
}
|
||||
answ.Add($"rgba(255, 99, 132, {alpha}");
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> solidColors(string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
answ.Add($"rgba(54, 162, 235, {alpha})");
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> lineColor
|
||||
{
|
||||
get => solidColors("1");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
@@ -171,7 +171,7 @@ namespace MP.Stats.Components
|
||||
/// <returns></returns>
|
||||
protected List<string> lineColors
|
||||
{
|
||||
get => calcColors(ParetoData.Count, 1);
|
||||
get => semaphColors(ParetoData.Count, "1");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -181,25 +181,7 @@ namespace MP.Stats.Components
|
||||
/// <returns></returns>
|
||||
protected List<string> bgColors
|
||||
{
|
||||
get => calcColors(ParetoData.Count, 0.3);
|
||||
}
|
||||
|
||||
protected async Task HandleRedraw()
|
||||
{
|
||||
if (ParetoGuasti != null)
|
||||
{
|
||||
#if false
|
||||
await ParetoGuasti.Clear();
|
||||
await ParetoGuasti.AddLabelsDatasetsAndUpdate(GetBarChartLabels(), GetBarChartDataset());
|
||||
#endif
|
||||
}
|
||||
if (NumGuasti != null)
|
||||
{
|
||||
#if false
|
||||
await NumGuasti.Clear();
|
||||
await NumGuasti.AddLabelsDatasetsAndUpdate(GetLineChartLabels(), GetLineChartDataset());
|
||||
#endif
|
||||
}
|
||||
get => semaphColors(ParetoData.Count, "0.3");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace MP.Stats.Pages
|
||||
protected List<string> lineColors = new List<string>();
|
||||
|
||||
|
||||
protected List<chartJsData.chartJsTSerie>? dataList { get; set; } = null;
|
||||
protected List<chartJsData.chartJsTSerie> dataList { get; set; } = new List<chartJsData.chartJsTSerie>();
|
||||
|
||||
string[] Labels = { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user