Aggiunta secondo metodo (da testare)
This commit is contained in:
@@ -69,13 +69,7 @@
|
||||
}
|
||||
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>
|
||||
<MultiLine Id="@currTsId" AspRatio="4" DataTSList="@TSDataMulti" Labels="@LabelPlot" lineColor="@lineColorsMLine" backColor="@bgColorsMLine" lTens="0" Titles="@lineTitles" Stepped="false"></MultiLine>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -9,19 +9,6 @@ namespace MP.IOC.Components.Pages
|
||||
{
|
||||
public partial class CallStats
|
||||
{
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected List<string> bgColors
|
||||
{
|
||||
get => semaphColors(currData.Count, "0.3");
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -35,20 +22,46 @@ namespace MP.IOC.Components.Pages
|
||||
|
||||
private List<StatDataDTO> currData = new();
|
||||
|
||||
private string currId = "";
|
||||
private string currHistId = "";
|
||||
private string currPieId = "";
|
||||
private string currTsId = "";
|
||||
private string currDetail = "";
|
||||
|
||||
private string currHistId = "";
|
||||
|
||||
private string currId = "";
|
||||
|
||||
private string currPieId = "";
|
||||
|
||||
private string currTitle = "";
|
||||
|
||||
private string currTsId = "";
|
||||
|
||||
private List<string> lineTitles = new List<string>();
|
||||
|
||||
private Dictionary<string, List<StatDataDTO>> ParetoDay = new();
|
||||
|
||||
private List<chartJsData.chartJsTSerie> tsData = new List<chartJsData.chartJsTSerie>();
|
||||
|
||||
private List<ChartSeriesDto> tsDataDetail = new();
|
||||
|
||||
private List<List<chartJsData.chartJsTSerie>> TSDataMulti = new();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<string> bgColors
|
||||
{
|
||||
get => GetSemaforicColors(currData.Count, "0.3");
|
||||
}
|
||||
|
||||
private List<string> bgColorsMLine
|
||||
{
|
||||
get => GetDistinctColors(tsDataDetail.Count, "0.3");
|
||||
}
|
||||
|
||||
private List<double> DatiPareto
|
||||
{
|
||||
get => currData.Select(x => x.Value).ToList();
|
||||
@@ -59,13 +72,23 @@ namespace MP.IOC.Components.Pages
|
||||
get => currData.Select(x => x.Label).ToList();
|
||||
}
|
||||
|
||||
private List<string> LabelPlot
|
||||
{
|
||||
get => tsData.Select(r => $"{r.x:yyyy-MM-dd}").ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<string> lineColors
|
||||
{
|
||||
get => semaphColors(currData.Count, "1");
|
||||
get => GetSemaforicColors(currData.Count, "1");
|
||||
}
|
||||
|
||||
private List<string> lineColorsMLine
|
||||
{
|
||||
get => GetDistinctColors(tsDataDetail.Count, "1");
|
||||
}
|
||||
|
||||
[Inject]
|
||||
@@ -134,9 +157,93 @@ namespace MP.IOC.Components.Pages
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
private List<string> GetSemaforicColors(int numRecords, string alpha)
|
||||
{
|
||||
List<string> colors = new List<string>();
|
||||
if (numRecords <= 0) return colors;
|
||||
if (numRecords == 1) { colors.Add($"rgba(54, 235, 82, {alpha})"); return colors; }
|
||||
|
||||
private string currDetail = "";
|
||||
// Definiamo i punti chiave (R, G, B)
|
||||
(int r, int g, int b) green = (54, 235, 82);
|
||||
(int r, int g, int b) yellow = (255, 206, 86);
|
||||
(int r, int g, int b) red = (255, 99, 132);
|
||||
|
||||
for (int i = 0; i < numRecords; i++)
|
||||
{
|
||||
// t va da 0.0 (primo record) a 1.0 (ultimo record)
|
||||
double t = (double)i / (numRecords - 1);
|
||||
int r, g, b;
|
||||
|
||||
if (t < 0.5)
|
||||
{
|
||||
// Da Verde a Giallo (mappiamo 0->0.5 su 0->1)
|
||||
double localT = t * 2;
|
||||
r = (int)(green.r + (yellow.r - green.r) * localT);
|
||||
g = (int)(green.g + (yellow.g - green.g) * localT);
|
||||
b = (int)(green.b + (yellow.b - green.b) * localT);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Da Giallo a Rosso (mappiamo 0.5->1 su 0->1)
|
||||
double localT = (t - 0.5) * 2;
|
||||
r = (int)(yellow.r + (red.r - yellow.r) * localT);
|
||||
g = (int)(yellow.g + (red.g - yellow.g) * localT);
|
||||
b = (int)(yellow.b + (red.b - yellow.b) * localT);
|
||||
}
|
||||
|
||||
colors.Add($"rgba({r}, {g}, {b}, {alpha})");
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
//private List<string> GetDistinctColors(int numRecords, string alpha)
|
||||
//{
|
||||
// List<string> colors = new List<string>();
|
||||
|
||||
// for (int i = 0; i < numRecords; i++)
|
||||
// {
|
||||
// // Distribuiamo la tonalità (Hue) uniformemente sui 360 gradi
|
||||
// double hue = (double)i * 360 / numRecords;
|
||||
|
||||
// // Usiamo il formato CSS hsla() che è più semplice da generare direttamente
|
||||
// // Saturazione 70% e Luminosità 50-60% di solito danno colori vivaci e distinti
|
||||
// colors.Add($"hsla({hue:0.##}, 70%, 50%, {alpha})");
|
||||
// }
|
||||
|
||||
// return colors;
|
||||
//}
|
||||
private List<string> GetDistinctColors(int numRecords, string alpha)
|
||||
{
|
||||
List<string> colors = new List<string>();
|
||||
if (numRecords <= 0) return colors;
|
||||
|
||||
// Partiamo dal Blu (240°) invece che dal Rosso (0°)
|
||||
double startHue = 240.0;
|
||||
|
||||
for (int i = 0; i < numRecords; i++)
|
||||
{
|
||||
// Distribuiamo la tonalità aggiungendo l'offset iniziale
|
||||
// L'operatore % 360 assicura di rimanere nel cerchio se superiamo il rosso
|
||||
double hue = (startHue + ((double)i * 360 / numRecords)) % 360;
|
||||
|
||||
// Strategia di distinzione (attiva sempre, ma più efficace sopra i 5 colori)
|
||||
// Alterniamo i valori per i record pari/dispari
|
||||
string saturation = "70%";
|
||||
string lightness = "50%";
|
||||
|
||||
if (numRecords > 5)
|
||||
{
|
||||
// Se i colori sono molti, alterniamo luminosità e saturazione
|
||||
// I record dispari saranno più chiari e saturi, i pari più scuri e tenui
|
||||
lightness = (i % 2 == 0) ? "45%" : "65%";
|
||||
saturation = (i % 2 == 0) ? "80%" : "60%";
|
||||
}
|
||||
|
||||
colors.Add($"hsla({hue:0.##}, {saturation}, {lightness}, {alpha})");
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// abilita visualizzaione grafico dettagli x metodo indicato
|
||||
@@ -148,7 +255,7 @@ namespace MP.IOC.Components.Pages
|
||||
// recupero dettaglio 7gg...
|
||||
DateTime adesso = DateTime.Now;
|
||||
List<StatsDetailModel> rawData = await SDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail);
|
||||
// conversione con grouping
|
||||
// conversione con grouping
|
||||
tsData = rawData.Select(r => new chartJsData.chartJsTSerie() { x = r.Hour, y = (double)r.AvgDuration })
|
||||
.OrderBy(o => o.x)
|
||||
.ToList();
|
||||
@@ -157,16 +264,6 @@ namespace MP.IOC.Components.Pages
|
||||
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>();
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace MP.IOC.Controllers
|
||||
[ApiController]
|
||||
public class IOBController : ControllerBase
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public IOBController(IConfiguration configuration, MpDataService DataService)
|
||||
{
|
||||
@@ -17,15 +18,7 @@ namespace MP.IOC.Controllers
|
||||
DService = DataService;
|
||||
}
|
||||
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected MpDataService DService { get; set; }
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -48,28 +41,27 @@ namespace MP.IOC.Controllers
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupera TASK richiesto x macchina:
|
||||
///
|
||||
/// GET: IOB/getOptPar/SIMUL_03
|
||||
/// GET: IOB/
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Json contenente 1..n task da eseguire</returns>
|
||||
[HttpGet("getOptPar/{id}")]
|
||||
public string getOptPar(string id)
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
public string alive()
|
||||
{
|
||||
string answ = "";
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
DService.ScriviKeepAlive(id, DateTime.Now);
|
||||
try
|
||||
{
|
||||
// leggo da REDIS eventuale elenco task x macchina...
|
||||
Dictionary<string, string> valori = DService.mOptParMacchina(id);
|
||||
answ = JsonConvert.SerializeObject(valori);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
return "OK";
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// GET: IOB/
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Alive()
|
||||
{
|
||||
return Ok("OK"); // Restituisce Status 200
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,6 +87,61 @@ namespace MP.IOC.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera TASK richiesto x macchina:
|
||||
///
|
||||
/// GET: IOB/getOptPar/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Json contenente 1..n task da eseguire</returns>
|
||||
[HttpGet("getOptPar/{id}")]
|
||||
public string getOptPar(string id)
|
||||
{
|
||||
string answ = "";
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
DService.ScriviKeepAlive(id, DateTime.Now);
|
||||
try
|
||||
{
|
||||
// leggo da REDIS eventuale elenco task x macchina...
|
||||
Dictionary<string, string> valori = DService.mOptParMacchina(id);
|
||||
answ = JsonConvert.SerializeObject(valori);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
[HttpGet("version")]
|
||||
public string version()
|
||||
{
|
||||
var version = Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetName()
|
||||
.Version?
|
||||
.ToString() ?? "unknown";
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected MpDataService DService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
///// <summary> AGGIUNGE TASK richiesto x macchina:
|
||||
/////
|
||||
///// GET: IOB/addTask2Exe/3010?taskName=startSetup&taskVal=T190406101512
|
||||
@@ -2217,22 +2264,6 @@ namespace MP.IOC.Controllers
|
||||
// }
|
||||
// return answ;
|
||||
//}
|
||||
|
||||
[HttpGet("version")]
|
||||
public string version()
|
||||
{
|
||||
var version = Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetName()
|
||||
.Version?
|
||||
.ToString() ?? "unknown";
|
||||
|
||||
return version;
|
||||
}
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
///// <summary>
|
||||
///// Effettua vera chiamata x salvataggio snapshot dati FluxLog
|
||||
///// </summary>
|
||||
@@ -2261,7 +2292,5 @@ namespace MP.IOC.Controllers
|
||||
|
||||
// return answ;
|
||||
//}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>6.16.2604.1016</Version>
|
||||
<Version>6.16.2604.1017</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 6.16.2604.1016</h4>
|
||||
<h4>Versione: 6.16.2604.1017</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2604.1016
|
||||
6.16.2604.1017
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2604.1016</version>
|
||||
<version>6.16.2604.1017</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