Update prima versione chart x IO/IOC
This commit is contained in:
@@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="DTO\ChartDataPointDto.cs" />
|
||||
<Compile Remove="DTO\ChartSeriesDto.cs" />
|
||||
<Compile Remove="DTO\FermiCommentatiDTO.cs" />
|
||||
<Compile Remove="DTO\userTknDTO.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MP.Data.DTO
|
||||
{
|
||||
public class ChartSeriesDto
|
||||
{
|
||||
public string SeriesName { get; set; }
|
||||
public List<chartJsData.chartJsTSerie> DataPoints { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <param name="sType">Tipo filtrato</param>
|
||||
Task<DtUtils.Periodo> GetRangeAsync(string sEnvir, string sType);
|
||||
|
||||
/// <summary>
|
||||
/// Helper conversione dati dettaglio in statistiche da inviare a ChartJS
|
||||
/// </summary>
|
||||
/// <param name="rawData"></param>
|
||||
/// <returns></returns>
|
||||
List<ChartSeriesDto> GetTimeSeriesData(List<StatsDetailModel> rawData);
|
||||
|
||||
/// <summary>
|
||||
/// Inserisce o aggiorna in batch le statistiche di dettaglio nel database.
|
||||
/// Opzionalmente elimina i record precedenti nel periodo specificato.
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<ChartSeriesDto> GetTimeSeriesData(List<StatsDetailModel> 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;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> UpsertManyAsync(List<StatsDetailModel> listRecords, bool removeOld)
|
||||
{
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
<script type="text/javascript" src="lib/bootstrap/js/bootstrap.min.js"></script>
|
||||
@* <script src="lib/Chart.js/chart.js"></script> *@
|
||||
<script src="lib/Chart.js/chart.umd.js"></script>
|
||||
@* <script src="lib/luxon/luxon.js"></script>
|
||||
<script src="lib/chartjs-adapter-luxon/chartjs-adapter-luxon.umd.js"></script> *@
|
||||
<script src="lib/luxon/luxon.js"></script>
|
||||
<script src="lib/chartjs-adapter-luxon/chartjs-adapter-luxon.umd.js"></script>
|
||||
<script src="lib/chartBoot.js"></script>
|
||||
</body>
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
responsive = true,
|
||||
scales = new
|
||||
{
|
||||
yAxes = new
|
||||
y = new
|
||||
{
|
||||
stacked = Stacked,
|
||||
type = "linear",
|
||||
@@ -102,14 +102,18 @@
|
||||
suggestedMin = MinValue != MaxValue ? MinValue : "auto",
|
||||
suggestedMax = MinValue != MaxValue ? MaxValue : "auto"
|
||||
},
|
||||
xAxes = new
|
||||
x = new
|
||||
{
|
||||
type = "time",
|
||||
time = new
|
||||
{
|
||||
unit = "hour" // Forza l'unità temporale se i dati sono orari
|
||||
},
|
||||
distribution = "linear",
|
||||
}
|
||||
},
|
||||
Animation = false,
|
||||
AspectRatio = AspRatio == 0 ? "auto" : $"{AspRatio}"
|
||||
animation = false,
|
||||
aspectRatio = AspRatio == 0 ? (object)null : AspRatio
|
||||
},
|
||||
data = new
|
||||
{
|
||||
|
||||
@@ -63,18 +63,23 @@
|
||||
else
|
||||
{
|
||||
<b>@currDetail</b>
|
||||
<i>timeserie selezionata x num call/tempo</i>
|
||||
if (tsDataDetail.Count == 0)
|
||||
{
|
||||
<div class="alert alert-info">← No data found</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>
|
||||
<b>@tsDataDetail.Count</b> values
|
||||
|
||||
@* <Line Id="TimeSerie" AspRatio="4" DataTS="@TSDataMulti.FirstOrDefault()" Labels="@LabelPlot" lineColor="@lineColors" backColor="@bgColors" lTens="0" Title="@lineTitles.FirstOrDefault()" Stepped="false"></Line> *@
|
||||
|
||||
<MultiLine Id="@currTsId" AspRatio="4" DataTSList="@TSDataMulti" Labels="@LabelPlot" lineColor="@lineColors" backColor="@bgColors" lTens="0" Titles="@lineTitles" Stepped="false"></MultiLine>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@* <div class="row small">
|
||||
@foreach (var item in ParetoDay)
|
||||
{
|
||||
<div class="col-4 mb-2">
|
||||
<ParetoDetail Title="@item.Key" ParetoList="@item.Value"></ParetoDetail>
|
||||
</div>
|
||||
}
|
||||
</div> *@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Core.DTO;
|
||||
using MP.Data;
|
||||
using MP.Data.DbModels.Utils;
|
||||
using MP.Data.DTO;
|
||||
using MP.Data.Services.Utils;
|
||||
|
||||
namespace MP.IOC.Components.Pages
|
||||
@@ -32,8 +35,11 @@ namespace MP.IOC.Components.Pages
|
||||
|
||||
private List<StatDataDTO> currData = new();
|
||||
|
||||
private string currId = "";
|
||||
private string currHistId = "";
|
||||
private string currPieId = "";
|
||||
private string currTsId = "";
|
||||
|
||||
|
||||
private string currTitle = "";
|
||||
|
||||
@@ -63,7 +69,7 @@ namespace MP.IOC.Components.Pages
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private IStatsDetailService StatsDetService { get; set; } = null!;
|
||||
private IStatsDetailService SDetService { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
@@ -71,13 +77,15 @@ namespace MP.IOC.Components.Pages
|
||||
|
||||
private string CheckSelect(string curKey)
|
||||
{
|
||||
return !string.IsNullOrEmpty(currHistId) && currHistId == curKey ? "active" : "";
|
||||
return !string.IsNullOrEmpty(currId) && currId == curKey ? "active" : "";
|
||||
}
|
||||
|
||||
private void DoReset()
|
||||
{
|
||||
currId = "";
|
||||
currHistId = "";
|
||||
currPieId = "";
|
||||
currTsId = "";
|
||||
currData = new();
|
||||
}
|
||||
|
||||
@@ -85,8 +93,10 @@ namespace MP.IOC.Components.Pages
|
||||
{
|
||||
if (ParetoDay.ContainsKey(reqKey))
|
||||
{
|
||||
currId = reqKey;
|
||||
currHistId = $"Bar_{reqKey}";
|
||||
currPieId = $"Pie_{reqKey}";
|
||||
currTsId = $"TS_{reqKey}";
|
||||
currTitle = $"Pareto | {reqKey}";
|
||||
currData = ParetoDay[reqKey];
|
||||
}
|
||||
@@ -94,7 +104,7 @@ namespace MP.IOC.Components.Pages
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
ParetoDay = await StatsDetService.GetParetoStatsDayAsync();
|
||||
ParetoDay = await SDetService.GetParetoStatsDayAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,7 +147,26 @@ namespace MP.IOC.Components.Pages
|
||||
currDetail = selDetail;
|
||||
// recupero dettaglio 7gg...
|
||||
DateTime adesso = DateTime.Now;
|
||||
var detailList = await StatsDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail);
|
||||
List<StatsDetailModel> rawData = await SDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail);
|
||||
// conversione con grouping
|
||||
tsData = rawData.Select(r => new chartJsData.chartJsTSerie() { x = r.Hour, y = (double)r.AvgDuration })
|
||||
.OrderBy(o => o.x)
|
||||
.ToList();
|
||||
tsDataDetail = SDetService.GetTimeSeriesData(rawData);
|
||||
lineTitles = tsDataDetail.Select(x => x.SeriesName).ToList();
|
||||
TSDataMulti = tsDataDetail.Select(x => x.DataPoints).ToList();
|
||||
}
|
||||
|
||||
private List<string> LabelPlot
|
||||
{
|
||||
get => tsData.Select(r => $"{r.x:yyyy-MM-dd}").ToList();
|
||||
}
|
||||
|
||||
private List<ChartSeriesDto> tsDataDetail = new();
|
||||
|
||||
private List<chartJsData.chartJsTSerie> tsData = new List<chartJsData.chartJsTSerie>();
|
||||
|
||||
private List<List<chartJsData.chartJsTSerie>> TSDataMulti = new();
|
||||
private List<string> lineTitles = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>6.16.2604.1014</Version>
|
||||
<Version>6.16.2604.1016</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 6.16.2604.1014</h4>
|
||||
<h4>Versione: 6.16.2604.1016</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2604.1014
|
||||
6.16.2604.1016
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2604.1014</version>
|
||||
<version>6.16.2604.1016</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user