diff --git a/MP.Stats/Components/ChartTrends.razor b/MP.Stats/Components/ChartTrends.razor
index 55d92f68..7711d35f 100644
--- a/MP.Stats/Components/ChartTrends.razor
+++ b/MP.Stats/Components/ChartTrends.razor
@@ -10,8 +10,14 @@
else
{
+
+ @foreach (PeriodoSel sPer in Enum.GetValues(typeof(PeriodoSel)))
+ {
+
+
+ }
+
-
Selezione tipo (day/week/month/year) + selezione ITEM da mostrare, tra quelli POSSIBILI dato periodo...
@foreach (var item in @ParetoData)
{
@@ -21,6 +27,7 @@
}
+
Selezione tipo (day/week/month/year) + selezione ITEM da mostrare, tra quelli POSSIBILI dato periodo...
- Day
-
- Week
-
- Month
-
- @* Year
- *@
+ Periodo
+
+ @pSel Detail
+
diff --git a/MP.Stats/Components/ChartTrends.razor.cs b/MP.Stats/Components/ChartTrends.razor.cs
index 6d8f9a95..897cd855 100644
--- a/MP.Stats/Components/ChartTrends.razor.cs
+++ b/MP.Stats/Components/ChartTrends.razor.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components;
+using MongoDB.Driver.Linq;
using MP.Data;
using MP.Data.DbModels;
using MP.Data.Services;
@@ -47,6 +48,7 @@ namespace MP.Stats.Components
{
get => semaphColors(ParetoData.Count, "0.3");
}
+ protected List bgColorsDet { get; set; } = new List();
///
/// Genera colori sfondo 33% rosso / arancione / giallo
@@ -65,6 +67,7 @@ namespace MP.Stats.Components
{
get => semaphColors(ParetoData.Count, "1");
}
+ protected List lineColorsDet { get; set; } = new List();
[Inject]
protected Data.MessageService MService { get; set; }
@@ -121,6 +124,7 @@ namespace MP.Stats.Components
#region Private Fields
private List lineTitles = new List() { "Consumo/UM" };
+ private List lineTitlesDet = new List() { "Consumo/UM" };
private string pieTitle = "Macchina";
#endregion Private Fields
@@ -146,6 +150,7 @@ namespace MP.Stats.Components
{
get => TSData.Select(r => $"{r.x:yyyy-MM-dd}").ToList();
}
+ private List LabelPlotDet { get; set; } = new List();
private int numMachine
{
@@ -155,6 +160,10 @@ namespace MP.Stats.Components
private List ParetoData { get; set; } = new List();
private List TSData { get; set; } = new List();
private List> TSDataMulti { get; set; } = new List>();
+ ///
+ /// TimeSeries su scala DAY
+ ///
+ private List> TSDataMultiDetail { get; set; } = new List>();
private List listMachine = new List();
@@ -166,24 +175,24 @@ namespace MP.Stats.Components
{
if (RawData != null)
{
- lineTitles = new List();
-
+ // reset preliminare
+ TSDataMulti.Clear();
+ TSDataMultiDetail.Clear();
+ lineTitles.Clear();
+ lineTitlesDet.Clear();
+ LabelPlotDet.Clear();
+ bgColorsDet.Clear();
+ lineColorsDet.Clear();
+ // calcolo i dati Pareto
ParetoData = RawData
//.GroupBy(p => new { p.IdxMacchina })
.GroupBy(p => new { p.IdxMacchina, p.CodFlux })
- //.Select(y => new ChartKV() { label = y.First().IdxMacchina, value = y.Count() })
+ //.Select(y => new ChartKV() { label = y.First().IdxMacchina, value = y.Count() })
.Select(y => new ChartKV() { label = $"{y.First().IdxMacchina} {TradService.Traduci($"MP-STATS_{y.First().CodFlux}")}", value = y.Count() })
.OrderByDescending(x => x.value)
.ToList();
- TSData = RawData
- .Select(r => new chartJsData.chartJsTSerie() { x = r.dtEvento, y = cDouble(r.Valore) })
- .OrderBy(o => o.x)
- .ToList();
-
- // reset lista
- TSDataMulti = new List>();
// ciclo x ogni macchina
listMachine = RawData
.GroupBy(x => x.IdxMacchina)
@@ -193,22 +202,145 @@ namespace MP.Stats.Components
foreach (var idxMacc in listMachine)
{
lineTitles.Add($"{idxMacc} | {TradService.Traduci("MP-STATS_TotEn01")}");
+ lineTitlesDet.Add($"{idxMacc} | {TradService.Traduci("MP-STATS_TotEn01")} - CURR");
+ lineTitlesDet.Add($"{idxMacc} | {TradService.Traduci("MP-STATS_TotEn01")} - PREV");
- var TSDataCurr = RawData
- .Where(x => x.IdxMacchina == idxMacc)
- .Select(r => new chartJsData.chartJsTSerie() { x = r.dtEvento, y = cDouble(r.Valore) })
- .OrderBy(o => o.x)
- .ToList();
- TSDataMulti.Add(TSDataCurr);
+ // periodo completo
+ TSDataMulti.Add(GetTSDetail(idxMacc, "", null));
+ // dettaglio richiesto...
+ var currPlot = GetTSDetail(idxMacc, "", pSel, true);
+ TSDataMultiDetail.Add(currPlot);
+ TSDataMultiDetail.Add(GetTSDetail(idxMacc, "", pSel, false));
+ if (LabelPlotDet.Count == 0)
+ {
+ if (pSel == PeriodoSel.Day)
+ {
+ LabelPlotDet = currPlot.Select(r => $"{r.x:HH:mm:ss}").ToList();
+ }
+ else
+ {
+ LabelPlotDet = currPlot.Select(r => $"{r.x:yyyy-MM-dd}").ToList();
+ }
+ }
}
+
+ bgColorsDet = semaphColors(ParetoData.Count * 2, "0.3");
+ lineColorsDet = semaphColors(ParetoData.Count * 2, "1");
}
}
+ private DateTime GetFirstDayOfWeek(DateTime date)
+ {
+ int offset = date.DayOfWeek - DayOfWeek.Sunday;
+ return date.AddDays(-offset);
+ }
+
+ ///
+ /// Ritorna dettaglio dato macchina e tipo (current o prev)
+ ///
+ /// Macchina richiesta
+ /// Flusso richiesto
+ /// Modo recap (se null --> intero periodo)
+ /// Indica se iin caso di recap sia periodo corrente/precedente
+ ///
+ private List GetTSDetail(string idxMacc, string codFlux, PeriodoSel? recapMode, bool isCurrent = true)
+ {
+ List answ = new();
+ if (!recapMode.HasValue)
+ {
+ answ = RawData
+ .Where(x => x.IdxMacchina == idxMacc)
+ .Select(r => new chartJsData.chartJsTSerie() { x = r.dtEvento, y = cDouble(r.Valore) })
+ .OrderBy(o => o.x)
+ .ToList();
+ }
+ else
+ {
+ // fake fix: indietro 7 gg...
+ DateTime dataRif = DateTime.Today.AddDays(-7);
+ DateTime inizio = dataRif;
+ DateTime fine = inizio.AddDays(1);
+ double startVal = 0;
+ switch (recapMode)
+ {
+ case PeriodoSel.Day:
+ inizio = isCurrent ? dataRif : dataRif.AddDays(-1);
+ fine = inizio.AddDays(1);
+ break;
+ case PeriodoSel.Week:
+ inizio = isCurrent ? GetFirstDayOfWeek(dataRif) : GetFirstDayOfWeek(dataRif).AddDays(-7);
+ fine = inizio.AddDays(7);
+ break;
+ case PeriodoSel.Month:
+ inizio = isCurrent ? new DateTime(dataRif.Year, dataRif.Month, 1) : new DateTime(dataRif.Year, dataRif.Month, 1).AddMonths(-1);
+ fine = inizio.AddMonths(1);
+ break;
+ case PeriodoSel.Year:
+ inizio = isCurrent ? new DateTime(dataRif.Year, 1, 1) : new DateTime(dataRif.Year, 1, 1).AddYears(-1);
+ fine = inizio.AddYears(1);
+ break;
+
+
+ case null:
+ default:
+ break;
+ }
+ // calcolo il minimo...
+ var listRaw = RawData
+ .Where(x => x.IdxMacchina == idxMacc && x.dtEvento >= inizio && x.dtEvento < fine)
+ .OrderBy(o => o.dtEvento)
+ .ToList();
+ var firstRec = listRaw
+ .FirstOrDefault();
+ if (firstRec != null)
+ {
+ startVal = cDouble(firstRec.Valore);
+ }
+
+ answ = listRaw
+ .Select(r => new chartJsData.chartJsTSerie() { x = r.dtEvento, y = cDouble(r.Valore) - startVal })
+ .OrderBy(o => o.x)
+ .ToList();
+ }
+
+ return answ;
+ }
+
private double cDouble(string origValue)
{
return double.Parse(origValue);
}
+ ///
+ /// Modalità selezione
+ ///
+ private PeriodoSel pSel;
+
+ protected enum PeriodoSel
+ {
+ Day,
+ Week,
+ Month,
+ Year
+ }
+
+ private void SetModo(PeriodoSel newModo)
+ {
+ pSel = newModo;
+ // ricalcolo!
+ RecalcData();
+ }
+
+ private string CssBtn(PeriodoSel reqMode)
+ {
+ string answ = "btn-outline-success";
+ if (reqMode == pSel)
+ {
+ answ = "btn-success text-light";
+ }
+ return answ;
+ }
+
#endregion Private Methods
}
}
\ No newline at end of file
diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj
index 4a9537d3..3e71c4d1 100644
--- a/MP.Stats/MP.Stats.csproj
+++ b/MP.Stats/MP.Stats.csproj
@@ -4,8 +4,8 @@
net6.0
MP.Stats
826e877c-ba70-4253-84cb-d0b1cafd4440
- 6.16.2503.1016
- 6.16.2503.1016
+ 6.16.2503.1018
+ 6.16.2503.1018
true
$(NoWarn);1591
en
diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html
index 6b9265e5..9b59fd50 100644
--- a/MP.Stats/Resources/ChangeLog.html
+++ b/MP.Stats/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo statistiche MAPO
- Versione: 6.16.2503.1016
+ Versione: 6.16.2503.1018
Note di rilascio:
diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt
index 1f6d83aa..55045ff0 100644
--- a/MP.Stats/Resources/VersNum.txt
+++ b/MP.Stats/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2503.1016
+6.16.2503.1018
diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml
index fed16b82..b340c612 100644
--- a/MP.Stats/Resources/manifest.xml
+++ b/MP.Stats/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2503.1016
+ 6.16.2503.1018
https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip
https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html
false