110 lines
2.9 KiB
C#
110 lines
2.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Core.DTO;
|
|
using MP.Data.Services.Utils;
|
|
|
|
namespace MP.IOC.Components.Pages
|
|
{
|
|
public partial class CallStats
|
|
{
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private Dictionary<string, List<StatDataDTO>> ParetoDay = new();
|
|
|
|
private void DoReset()
|
|
{
|
|
currSelect = "";
|
|
currData = new();
|
|
}
|
|
private void DoSelect(string reqKey)
|
|
{
|
|
if (ParetoDay.ContainsKey(reqKey))
|
|
{
|
|
currSelect = reqKey;
|
|
currTitle = $"Pareto | {reqKey}";
|
|
currData = ParetoDay[reqKey];
|
|
}
|
|
}
|
|
private string currSelect = "";
|
|
private string currTitle = "";
|
|
private List<StatDataDTO> currData = new();
|
|
|
|
private List<string> LabelPareto
|
|
{
|
|
get => currData.Select(x => x.Label).ToList();
|
|
}
|
|
|
|
private List<double> DatiPareto
|
|
{
|
|
get => currData.Select(x => x.Value).ToList();
|
|
}
|
|
/// <summary>
|
|
/// Genera colori sfondo 33% rosso / arancione / giallo
|
|
/// </summary>
|
|
/// <param name="numRecords"></param>
|
|
/// <param name="alpha"></param>
|
|
/// <returns></returns>
|
|
private List<string> semaphColors(int numRecords, string alpha)
|
|
{
|
|
List<string> answ = new List<string>();
|
|
// verde...
|
|
for (int i = 0; i < numRecords / 3; i++)
|
|
{
|
|
answ.Add($"rgba(54, 235, 82, {alpha})");
|
|
}
|
|
// arancione
|
|
for (int i = 0; i < numRecords / 3; i++)
|
|
{
|
|
answ.Add($"rgba(255, 206, 86, {alpha})");
|
|
}
|
|
while (answ.Count < numRecords)
|
|
{
|
|
answ.Add($"rgba(255, 99, 132, {alpha}");
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Genera colori sfondo 33% rosso / arancione / giallo
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected List<string> bgColors
|
|
{
|
|
get => semaphColors(currData.Count, "0.3");
|
|
}
|
|
/// <summary>
|
|
/// Genera colori sfondo 33% rosso / arancione / giallo
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private List<string> lineColors
|
|
{
|
|
get => semaphColors(currData.Count, "1");
|
|
}
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IStatsDetailService StatsDetService { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
ParetoDay = await StatsDetService.GetParetoStatsDayAsync();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |