diff --git a/EgwCoreLib.BlazorTest/Data/TestData.cs b/EgwCoreLib.BlazorTest/Data/TestData.cs index 4908dc1..f932f5c 100644 --- a/EgwCoreLib.BlazorTest/Data/TestData.cs +++ b/EgwCoreLib.BlazorTest/Data/TestData.cs @@ -13,6 +13,7 @@ namespace EgwCoreLib.BlazorTest.Data {"TestBarcodeReader", "Test Barcode Read"}, {"TestCalendario", "Test Calendario"}, {"TestProgress", "Test Progress"}, + {"TestParetoProgress", "Test Pareto ProgressBar"}, {"TestLoading", "Test Loading"}, {"TestComponenti", "Test Componenti"}, {"TestSvgDraw", "Test SVG draw"}, diff --git a/EgwCoreLib.BlazorTest/Pages/TestParetoProgress.razor b/EgwCoreLib.BlazorTest/Pages/TestParetoProgress.razor new file mode 100644 index 0000000..3bcd5b6 --- /dev/null +++ b/EgwCoreLib.BlazorTest/Pages/TestParetoProgress.razor @@ -0,0 +1,41 @@ +@page "/TestParetoProgress" + + +
+
+

Test Pareto ProgressBar

+
+
+
+ @foreach (var dataSet in ListParetoTime) + { +
+ +
+ } +
+
+
+ + +@code { + private List> ListParetoTime = new(); + + + private Random rnd = new(); + protected override void OnInitialized() + { + base.OnInitialized(); + ListParetoTime = new(); + // simulazione... + for (int i = 0; i < 9; i++) + { + Dictionary currSet = new(); + currSet.Add("success", rnd.Next(2, 10)); + currSet.Add("warning", rnd.Next(0, 10)); + currSet.Add("danger", rnd.Next(1, 10)); + ListParetoTime.Add(currSet); + } + // fatto! + } +} diff --git a/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj b/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj index b680d11..e64a332 100644 --- a/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj +++ b/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj @@ -107,4 +107,8 @@ + + + + diff --git a/EgwCoreLib.Razor/ParetoProgress.razor b/EgwCoreLib.Razor/ParetoProgress.razor new file mode 100644 index 0000000..07f0c04 --- /dev/null +++ b/EgwCoreLib.Razor/ParetoProgress.razor @@ -0,0 +1,83 @@ +@using System.Collections.Generic +@using System.Globalization + +
+ @if (!string.IsNullOrWhiteSpace(Title)) + { +
+ @Title + @if (Total > 0) + { + Totale: @Total + } +
+ } + + @if (Total > 0) + { +
+
+ @if (ShowIcon) + { + ✅ OK: + } + @success +
+
+ @if (ShowIcon) + { + ⚠️ Warning: + } + @warning +
+
+ @if (ShowIcon) + { + 🚨 Danger: + } + @danger +
+
+ } + else + { +
Nessun record
+ } +
+ +@code { + /// + /// Dizionario valori dussiviso tra success/warning/danger + /// + [Parameter] + public Dictionary? ParetoData { get; set; } + + /// + /// Titolo del display + /// + [Parameter] + public string Title { get; set; } = "Distribuzione"; + + /// + /// Indica se mostrare icona insieme al numero dentro i blocchi + /// + [Parameter] + public bool ShowIcon { get; set; } = false; + + + private string CalcPctCss(double currVal) + { + var dblVal = Total > 0 ? currVal / (double)Total * 100 : 0; + return $"{dblVal.ToString("F1", CultureInfo.InvariantCulture)}%"; + } + + // Proprietà calcolate con fallback sicuro + private int success => ParetoData?.GetValueOrDefault("success", 0) ?? 0; + private int warning => ParetoData?.GetValueOrDefault("warning", 0) ?? 0; + private int danger => ParetoData?.GetValueOrDefault("danger", 0) ?? 0; + private int Total => success + warning + danger; + + private double SuccessPct => Total > 0 ? (success / (double)Total) * 100 : 0; + private double WarningPct => Total > 0 ? (warning / (double)Total) * 100 : 0; + private double DangerPct => Total > 0 ? (danger / (double)Total) * 100 : 0; +} \ No newline at end of file