using Microsoft.AspNetCore.Components;
using MP.Core.DTO;
using MP.Data.Services.Utils;
namespace MP.IOC.Components.Pages
{
public partial class CallStats
{
#region Protected Properties
///
/// Genera colori sfondo 33% rosso / arancione / giallo
///
///
protected List bgColors
{
get => semaphColors(currData.Count, "0.3");
}
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
#endregion Protected Methods
#region Private Fields
private List currData = new();
private string currHistId = "";
private string currPieId = "";
private string currTitle = "";
private Dictionary> ParetoDay = new();
#endregion Private Fields
#region Private Properties
private List DatiPareto
{
get => currData.Select(x => x.Value).ToList();
}
private List LabelPareto
{
get => currData.Select(x => x.Label).ToList();
}
///
/// Genera colori sfondo 33% rosso / arancione / giallo
///
///
private List lineColors
{
get => semaphColors(currData.Count, "1");
}
[Inject]
private IStatsDetailService StatsDetService { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private string CheckSelect(string curKey)
{
return !string.IsNullOrEmpty(currHistId) && currHistId == curKey ? "active" : "";
}
private void DoReset()
{
currHistId = "";
currPieId = "";
currData = new();
}
private void DoSelect(string reqKey)
{
if (ParetoDay.ContainsKey(reqKey))
{
currHistId = $"Bar_{reqKey}";
currPieId = $"Pie_{reqKey}";
currTitle = $"Pareto | {reqKey}";
currData = ParetoDay[reqKey];
}
}
private async Task ReloadData()
{
ParetoDay = await StatsDetService.GetParetoStatsDayAsync();
}
///
/// Genera colori sfondo 33% rosso / arancione / giallo
///
///
///
///
private List semaphColors(int numRecords, string alpha)
{
List answ = new List();
// 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;
}
#endregion Private Methods
private string currDetail = "";
///
/// abilita visualizzaione grafico dettagli x metodo indicato
///
///
private async Task ShowDetail(string selDetail)
{
currDetail = selDetail;
// recupero dettaglio 7gg...
DateTime adesso = DateTime.Now;
var detailList = await StatsDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail);
}
}
}