diff --git a/MP.Core/DTO/ChartDataPointDto.cs b/MP.Core/DTO/ChartDataPointDto.cs
deleted file mode 100644
index 087d2c6f..00000000
--- a/MP.Core/DTO/ChartDataPointDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace MP.Core.DTO
-{
- public class ChartDataPointDto
- {
- }
-}
diff --git a/MP.Core/DTO/ChartSeriesDto.cs b/MP.Core/DTO/ChartSeriesDto.cs
deleted file mode 100644
index 98f134b0..00000000
--- a/MP.Core/DTO/ChartSeriesDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace MP.Core.DTO
-{
- internal class ChartSerieDTO
- {
- }
-}
diff --git a/MP.Core/MP.Core.csproj b/MP.Core/MP.Core.csproj
index 687d58ca..ad90e90c 100644
--- a/MP.Core/MP.Core.csproj
+++ b/MP.Core/MP.Core.csproj
@@ -7,6 +7,8 @@
+
+
diff --git a/MP.Data/DTO/ChartSeriesDto.cs b/MP.Data/DTO/ChartSeriesDto.cs
new file mode 100644
index 00000000..8fa40f29
--- /dev/null
+++ b/MP.Data/DTO/ChartSeriesDto.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+
+namespace MP.Data.DTO
+{
+ public class ChartSeriesDto
+ {
+ public string SeriesName { get; set; }
+ public List DataPoints { get; set; }
+ }
+}
diff --git a/MP.Data/Services/Utils/IStatsDetailService.cs b/MP.Data/Services/Utils/IStatsDetailService.cs
index e8567d7e..c193815b 100644
--- a/MP.Data/Services/Utils/IStatsDetailService.cs
+++ b/MP.Data/Services/Utils/IStatsDetailService.cs
@@ -1,6 +1,7 @@
using EgwCoreLib.Utils;
using MP.Core.DTO;
using MP.Data.DbModels.Utils;
+using MP.Data.DTO;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -47,6 +48,13 @@ namespace MP.Data.Services.Utils
/// Tipo filtrato
Task GetRangeAsync(string sEnvir, string sType);
+ ///
+ /// Helper conversione dati dettaglio in statistiche da inviare a ChartJS
+ ///
+ ///
+ ///
+ List GetTimeSeriesData(List rawData);
+
///
/// Inserisce o aggiorna in batch le statistiche di dettaglio nel database.
/// Opzionalmente elimina i record precedenti nel periodo specificato.
diff --git a/MP.Data/Services/Utils/StatsDetailService.cs b/MP.Data/Services/Utils/StatsDetailService.cs
index 19b482f5..b47cfd94 100644
--- a/MP.Data/Services/Utils/StatsDetailService.cs
+++ b/MP.Data/Services/Utils/StatsDetailService.cs
@@ -2,6 +2,7 @@
using Microsoft.Extensions.Configuration;
using MP.Core.DTO;
using MP.Data.DbModels.Utils;
+using MP.Data.DTO;
using MP.Data.Repository.Utils;
using StackExchange.Redis;
using System;
@@ -98,6 +99,32 @@ namespace MP.Data.Services.Utils
});
}
+ ///
+ public List GetTimeSeriesData(List rawData)
+ {
+ var series = rawData
+ .GroupBy(s => new { s.Destination, s.Type }) // Raggruppiamo per la chiave composta
+ .Select(group => new ChartSeriesDto
+ {
+ // Creiamo un nome leggibile per la legenda del grafico
+ SeriesName = $"{group.Key.Destination}|{group.Key.Type}",
+
+ // Per ogni gruppo, creiamo la lista dei punti temporali
+ DataPoints = group
+ .OrderBy(p => p.Hour) // Fondamentale: l'asse X deve essere cronologico
+ .Select(p => new chartJsData.chartJsTSerie
+ {
+ x = p.Hour,
+ y = p.AvgDuration // La metrica richiesta
+ })
+ .ToList()
+ })
+ .OrderBy(s => s.SeriesName) // Opzionale: ordina le serie alfabeticamente
+ .ToList();
+
+ return series;
+ }
+
///
public async Task UpsertManyAsync(List listRecords, bool removeOld)
{
diff --git a/MP.IOC/Components/App.razor b/MP.IOC/Components/App.razor
index 50f26fdc..4e40c9ab 100644
--- a/MP.IOC/Components/App.razor
+++ b/MP.IOC/Components/App.razor
@@ -21,8 +21,8 @@
@* *@
-@*
- *@
+
+