From 557a9510d6ca6d034c6b69ea09e72bc6643d801e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 25 Feb 2022 20:19:34 +0100 Subject: [PATCH] Fix grafico pareto guasti con componente standard! --- MP.Stats/Components/ChartJs/BarPlot.razor | 8 +- MP.Stats/Components/ChartJs/PieChart.razor | 2 +- MP.Stats/Components/ChartOEE.razor | 7 +- MP.Stats/Components/ChartOEE.razor.cs | 109 +++++++-------------- MP.Stats/MP.Stats.csproj | 2 +- MP.Stats/Pages/Test.razor | 4 +- MP.Stats/Resources/ChangeLog.html | 2 +- MP.Stats/Resources/VersNum.txt | 2 +- MP.Stats/Resources/manifest.xml | 2 +- 9 files changed, 50 insertions(+), 88 deletions(-) diff --git a/MP.Stats/Components/ChartJs/BarPlot.razor b/MP.Stats/Components/ChartJs/BarPlot.razor index db7405ad..dd900386 100644 --- a/MP.Stats/Components/ChartJs/BarPlot.razor +++ b/MP.Stats/Components/ChartJs/BarPlot.razor @@ -12,12 +12,12 @@ [Parameter] public bool Horizontal { get; set; } = false; + + [Parameter] + public List Data { get; set; } = new List(); [Parameter] - public string[]? Data { get; set; } - - [Parameter] - public string[]? Labels { get; set; } + public List Labels { get; set; } = new List(); [Parameter] public double AspRatio { get; set; } = 0; diff --git a/MP.Stats/Components/ChartJs/PieChart.razor b/MP.Stats/Components/ChartJs/PieChart.razor index 36a80035..d1dab00f 100644 --- a/MP.Stats/Components/ChartJs/PieChart.razor +++ b/MP.Stats/Components/ChartJs/PieChart.razor @@ -9,7 +9,7 @@ public string Id { get; set; } = "MyTs"; [Parameter] - public List Data { get; set; } = null!; + public List Data { get; set; } = new List(); [Parameter] public List Labels { get; set; } = new List(); diff --git a/MP.Stats/Components/ChartOEE.razor b/MP.Stats/Components/ChartOEE.razor index dfd20a4b..cbf95bee 100644 --- a/MP.Stats/Components/ChartOEE.razor +++ b/MP.Stats/Components/ChartOEE.razor @@ -1,4 +1,7 @@ -
+ +@using MP.Stats.Components.ChartJs + +
@if (RawData == null || RawData.Count == 0) {
@@ -21,7 +24,7 @@
- @**@ +
@**@ diff --git a/MP.Stats/Components/ChartOEE.razor.cs b/MP.Stats/Components/ChartOEE.razor.cs index 1e425a08..f867296d 100644 --- a/MP.Stats/Components/ChartOEE.razor.cs +++ b/MP.Stats/Components/ChartOEE.razor.cs @@ -11,75 +11,7 @@ namespace MP.Stats.Components { #region Protected Fields - protected object barChartOptions = new - { - Scales = new - { - XAxes = new object[] - { - new { - Display = false - } - }, - YAxes = new object[] - { - new { - Display = true, - ticks= new { - suggestedMin = 0 - } - } - } - }, - Tooltips = new - { - Mode = "nearest", - Intersect = false - }, - Hover = new - { - Mode = "nearest", - Intersect = false - }, - Animation = false, - AspectRatio = 3.5 - }; - - protected object lineChartOptions = new - { - Scales = new - { - XAxes = new object[] - { - new { - Display = true, - //type = "time" - } - }, - YAxes = new object[] - { - new { - Display = true, - ticks= new { - min = 0, - max = 100 - } - } - } - }, - Tooltips = new - { - Mode = "nearest", - Intersect = false - }, - Hover = new - { - Mode = "nearest", - Intersect = false - }, - Animation = false, - AspectRatio = 3.5 - }; + protected List NumGuasti = new List(); @@ -169,6 +101,15 @@ namespace MP.Stats.Components } #endif + private List DatiGuasti + { + get => ParetoData.Select(x => x.value).ToList(); + } + private List LabelGuasti + { + get => ParetoData.Select(x => x.label).ToList(); + } + private List GetLineChartLabels() { var answ = TSData.Select(x => x.TLabel.ToString("ddd dd.MM")).ToList(); @@ -202,29 +143,47 @@ namespace MP.Stats.Components /// /// /// - protected List backgroundColors(int numRecords, float alpha) + protected List calcColors(int numRecords, double alpha) { List answ = new List(); -#if false // verde... for (int i = 0; i < numRecords / 3; i++) { - answ.Add(ChartColor.FromRgba(54, 235, 82, alpha)); + answ.Add($"rgba(54, 235, 82, {alpha.ToString("N2").Replace(",", ".")})"); } // arancione for (int i = 0; i < numRecords / 3; i++) { - answ.Add(ChartColor.FromRgba(255, 206, 86, alpha)); + answ.Add($"rgba(255, 206, 86, {alpha.ToString("N2").Replace(",", ".")})"); } while (answ.Count < numRecords) { - answ.Add(ChartColor.FromRgba(255, 99, 132, alpha)); + answ.Add($"rgba(255, 99, 132, {alpha.ToString("N2").Replace(",",".")}"); } -#endif return answ; } + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + /// + protected List lineColors + { + get => calcColors(ParetoData.Count, 1); + } + + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + /// + protected List bgColors + { + get => calcColors(ParetoData.Count, 0.3); + } + protected async Task HandleRedraw() { if (ParetoGuasti != null) diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index c053b441..a32f33cc 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -4,7 +4,7 @@ net6.0 MP.Stats 826e877c-ba70-4253-84cb-d0b1cafd4440 - 6.14.2202.2519 + 6.14.2202.2520 diff --git a/MP.Stats/Pages/Test.razor b/MP.Stats/Pages/Test.razor index 30eabcdf..14b1b131 100644 --- a/MP.Stats/Pages/Test.razor +++ b/MP.Stats/Pages/Test.razor @@ -36,13 +36,13 @@
- +
- +
diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html index 65b5745a..4dc55ed7 100644 --- a/MP.Stats/Resources/ChangeLog.html +++ b/MP.Stats/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

Versione: 6.14.2202.2519

+

Versione: 6.14.2202.2520


Note di rilascio:
    diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt index 1e2593fa..8341d8db 100644 --- a/MP.Stats/Resources/VersNum.txt +++ b/MP.Stats/Resources/VersNum.txt @@ -1 +1 @@ -6.14.2202.2519 +6.14.2202.2520 diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml index 3d74f814..e96cd506 100644 --- a/MP.Stats/Resources/manifest.xml +++ b/MP.Stats/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.14.2202.2519 + 6.14.2202.2520 https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html false