From a77d77fcfae6a13a7dc1321aa0888d9940da82e1 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 11 Mar 2025 07:34:11 +0100 Subject: [PATCH] STATS: ok display trends --- MP.Stats/Components/ChartTrends.razor | 40 ++++++++++++++++-------- MP.Stats/Components/ChartTrends.razor.cs | 40 +++++++++++++++++++++--- 2 files changed, 62 insertions(+), 18 deletions(-) diff --git a/MP.Stats/Components/ChartTrends.razor b/MP.Stats/Components/ChartTrends.razor index 7711d35f..bb47f23a 100644 --- a/MP.Stats/Components/ChartTrends.razor +++ b/MP.Stats/Components/ChartTrends.razor @@ -10,12 +10,22 @@ else {
+
+
+
    +
  • + Sel.Dettaglio +
  • + @foreach (PeriodoSel sPer in Enum.GetValues(typeof(PeriodoSel))) + { +
  • + +
  • + } +
+
+
- @foreach (PeriodoSel sPer in Enum.GetValues(typeof(PeriodoSel))) - { - - - }
    @@ -27,19 +37,23 @@ }
- Selezione tipo (day/week/month/year) + selezione ITEM da mostrare, tra quelli POSSIBILI dato periodo... + selezione ITEM da mostrare, tra quelli POSSIBILI dato periodo...
-
+ @*
-
-
- Periodo - - @pSel Detail - +
*@ +
+
+ @pSel Detail +
+ +
+ Periodo +
+
diff --git a/MP.Stats/Components/ChartTrends.razor.cs b/MP.Stats/Components/ChartTrends.razor.cs index acb3cfe9..451e8e9f 100644 --- a/MP.Stats/Components/ChartTrends.razor.cs +++ b/MP.Stats/Components/ChartTrends.razor.cs @@ -238,8 +238,8 @@ namespace MP.Stats.Components #endif } - bgColorsDet = semaphColors(ParetoData.Count * 2, "0.3"); - lineColorsDet = semaphColors(ParetoData.Count * 2, "1"); + bgColorsDet = cpColors(ParetoData.Count, "0.3"); + lineColorsDet = cpColors(ParetoData.Count, "1"); } } @@ -249,6 +249,36 @@ namespace MP.Stats.Components return date.AddDays(-offset); } + + /// + /// Genera colori sfondo alternat full / quasi grigi (x preious data) + /// + /// numero record CURRENT + /// + /// + protected List cpColors(int numRecords, string alpha) + { + List answ = new List(); + int r = 0; + int g = 0; + int b = 0; + // ciclo x numRecords-1 + for (int j = 0; j < numRecords; j++) + { + r = 54 + (180 - 54) * j / numRecords; + g = 86 + (35 - 86) * j / numRecords; + b = 254 + (180 - 254) * j / numRecords; + answ.Add($"rgba({r}, {g}, {b}, {alpha}"); + answ.Add($"rgba({(510 + r) / 3},{(510 + g) / 3},{(510 + b) / 3}, {alpha}"); + } + // chiude + while (answ.Count < numRecords) + { + answ.Add($"rgba(180, 180, 35, {alpha})"); + } + return answ; + } + /// /// Ritorna dettaglio dato macchina e tipo (current o prev) /// @@ -271,7 +301,7 @@ namespace MP.Stats.Components else { // fake fix: indietro 7 gg... - DateTime dataRif = DateTime.Today.AddDays(-7); + DateTime dataRif = DateTime.Today;//.AddDays(-7); TimeSpan deltaOld = new TimeSpan(0); DateTime dtStart = dataRif; DateTime inizio = dataRif; @@ -356,10 +386,10 @@ namespace MP.Stats.Components private string CssBtn(PeriodoSel reqMode) { - string answ = "btn-outline-success"; + string answ = "btn-outline-dark"; if (reqMode == pSel) { - answ = "btn-success text-light"; + answ = "btn-dark text-light"; } return answ; }