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> 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 currData = new(); private List LabelPareto { get => currData.Select(x => x.Label).ToList(); } private List DatiPareto { get => currData.Select(x => x.Value).ToList(); } /// /// 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; } /// /// Genera colori sfondo 33% rosso / arancione / giallo /// /// protected List bgColors { get => semaphColors(currData.Count, "0.3"); } /// /// Genera colori sfondo 33% rosso / arancione / giallo /// /// private List 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 } }