diff --git a/MP.Stats/Components/ChartJs/Line.razor b/MP.Stats/Components/ChartJs/Line.razor index 53b43065..8fd09cc2 100644 --- a/MP.Stats/Components/ChartJs/Line.razor +++ b/MP.Stats/Components/ChartJs/Line.razor @@ -84,7 +84,7 @@ }, xAxes = new { - type = "timeseries", + type = "time", distribution = "linear", } }, @@ -93,7 +93,7 @@ }, data = new { - //labels = Labels.ToArray(), + labels = Labels, datasets = new[] { new diff --git a/MP.Stats/Components/ChartOEE.razor b/MP.Stats/Components/ChartOEE.razor index e7bbdcb9..92bd0d85 100644 --- a/MP.Stats/Components/ChartOEE.razor +++ b/MP.Stats/Components/ChartOEE.razor @@ -1,35 +1,34 @@ - -@using MP.Stats.Components.ChartJs +@using MP.Stats.Components.ChartJs
@if (RawData == null || RawData.Count == 0) { -
-
No Chart Data
-
+
+
No Chart Data
+
} else { -
- +
+
+
+
+ +
+
+ +
-
} \ No newline at end of file diff --git a/MP.Stats/Components/ChartOEE.razor.cs b/MP.Stats/Components/ChartOEE.razor.cs index 9bcbfe89..a74d0f3a 100644 --- a/MP.Stats/Components/ChartOEE.razor.cs +++ b/MP.Stats/Components/ChartOEE.razor.cs @@ -13,11 +13,6 @@ namespace MP.Stats.Components #region Protected Fields - - protected List NumGuasti = new List(); - - protected List ParetoGuasti = new List(); - #endregion Protected Fields #region Protected Properties @@ -76,7 +71,7 @@ namespace MP.Stats.Components } private List LabelTrs { - get => TSData.Select(r => $"{r.x:dd.MM}").ToList(); + get => TSData.Select(r => $"{r.x:yyyy-MM-dd}").ToList(); } private Dictionary calcTSData(DateTime inizio, List yData) diff --git a/MP.Stats/Components/ChartScarti.razor b/MP.Stats/Components/ChartScarti.razor index daf5d238..e240f504 100644 --- a/MP.Stats/Components/ChartScarti.razor +++ b/MP.Stats/Components/ChartScarti.razor @@ -1,4 +1,6 @@ -@*
+@using MP.Stats.Components.ChartJs + +
@if (RawData == null || RawData.Count == 0) {
@@ -21,12 +23,12 @@
- +
- +
} -
*@ \ No newline at end of file +
\ No newline at end of file diff --git a/MP.Stats/Components/ChartScarti.razor.cs b/MP.Stats/Components/ChartScarti.razor.cs index 76b2c7a7..7e4e1414 100644 --- a/MP.Stats/Components/ChartScarti.razor.cs +++ b/MP.Stats/Components/ChartScarti.razor.cs @@ -1,9 +1,8 @@ -using System; +using Microsoft.AspNetCore.Components; +using MP.Data; +using MP.Stats.Data; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; -using MP.Stats.Data; namespace MP.Stats.Components { @@ -80,20 +79,68 @@ namespace MP.Stats.Components AspectRatio = 3.5 }; -#if false - protected LineChart NumGuasti = new LineChart(); - - protected BarChart ParetoGuasti = new BarChart(); -#endif - #endregion Protected Fields + #region Private Properties + + private List DatiPareto + { + get => ParetoData.Select(x => x.value).ToList(); + } + + private List DatiPlot + { + get => TSData; + } + + private List LabelPareto + { + get => ParetoData.Select(x => x.label).ToList(); + } + + private List LabelPlot + { + get => TSData.Select(r => $"{r.x:yyyy-MM-dd}").ToList(); + } + + #endregion Private Properties + #region Protected Properties protected SelectData _currFilter { get; set; } = new SelectData(); protected List _rawData { get; set; } = new List(); + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + /// + protected List bgColors + { + get => semaphColors(ParetoData.Count, "0.3"); + } + + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + /// + protected List lineColor + { + get => solidColors("1"); + } + + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + /// + protected List lineColors + { + get => semaphColors(ParetoData.Count, "1"); + } + [Inject] protected MessageService MessageService { get; set; } @@ -102,7 +149,7 @@ namespace MP.Stats.Components [Inject] protected MpStatsService StatService { get; set; } - protected List TSData { get; set; } = new List(); + protected List TSData { get; set; } = new List(); #endregion Protected Properties @@ -120,10 +167,6 @@ namespace MP.Stats.Components { // ricalcolo charting data recalcData(); - var dataReload = Task.Run(async () => - { - await HandleRedraw(); - }); } } } @@ -132,50 +175,6 @@ namespace MP.Stats.Components #region Private Methods -#if false - private BarChartDataset GetBarChartDataset() - { - var answ = new BarChartDataset - { - Label = "Pareto Causali Scarto", - Data = ParetoData.Select(x => x.value).ToList(), - BackgroundColor = backgroundColors(ParetoData.Count, 0.4f), - BorderColor = backgroundColors(ParetoData.Count, 1f), - HoverBorderWidth = 5 - }; - return answ; - } -#endif - - private List GetBarChartLabels() - { - var answ = ParetoData.Select(x => x.label).ToList(); - return answ; - } - -#if false - private LineChartDataset GetLineChartDataset() - { - var answ = new LineChartDataset - { - Label = "Numero Scarti Periodo", - Data = TSData.Select(x => x.Value).ToList(), - BorderColor = backgroundColors(1, 1f), - Fill = true, - PointRadius = 2, - SteppedLine = true, - BorderDash = new List { } - }; - return answ; - } -#endif - - private List GetLineChartLabels() - { - var answ = TSData.Select(x => x.TLabel.ToString("ddd dd.MM")).ToList(); - return answ; - } - private void recalcData() { if (RawData != null) @@ -188,8 +187,8 @@ namespace MP.Stats.Components TSData = RawData .GroupBy(x => x.DataOraRif.Date) - .Select(y => new ChartTS() { TLabel = y.First().DataOraRif.Date, Value = y.Sum(c => c.Qta) }) - .OrderBy(x => x.TLabel) + .Select(r => new chartJsData.chartJsTSerie() { x = r.First().DataOraRif.Date, y = r.Sum(c => c.Qta) }) + .OrderBy(o => o.x) .ToList(); } } @@ -198,50 +197,43 @@ namespace MP.Stats.Components #region Protected Methods + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + /// + protected List semaphColors(int numRecords, string alpha) + { + List answ = new List(); + int numStep = 5; + // ciclo x numStep-1 + for (int j = 0; j < numStep; j++) + { + for (int i = 0; i < numRecords / numStep; i++) + { + answ.Add($"rgba(255, {82 + (206 - 82) * j / numStep}, {132 + (74 - 132) * j / numStep}, {alpha}"); + } + } + // chiude + while (answ.Count < numRecords) + { + answ.Add($"rgba(255, 206, 86, {alpha})"); + } + + return answ; + } + /// /// Genera colori sfondo 33% rosso / arancione / giallo /// /// /// - protected List backgroundColors(int numRecords, float alpha) + protected List solidColors(string alpha) { List answ = new List(); -#if false - // rosso... - for (int i = 0; i < numRecords / 3; i++) - { - answ.Add(ChartColor.FromRgba(255, 99, 132, alpha)); - } - // arancione - for (int i = 0; i < numRecords / 3; i++) - { - answ.Add(ChartColor.FromRgba(255, 206, 86, alpha)); - } - while (answ.Count < numRecords) - { - answ.Add(ChartColor.FromRgba(54, 82, 235, alpha)); - } -#endif - + answ.Add($"rgba(54, 162, 235, {alpha})"); return answ; } - protected async Task HandleRedraw() - { -#if false - if (ParetoGuasti != null) - { - await ParetoGuasti.Clear(); - await ParetoGuasti.AddLabelsDatasetsAndUpdate(GetBarChartLabels(), GetBarChartDataset()); - } - if (NumGuasti != null) - { - await NumGuasti.Clear(); - await NumGuasti.AddLabelsDatasetsAndUpdate(GetLineChartLabels(), GetLineChartDataset()); - } -#endif - } - #endregion Protected Methods } } \ No newline at end of file diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index d78a0eab..20566bd4 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.2612 + 6.14.2202.2613 diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html index 634c73ce..5a9b302d 100644 --- a/MP.Stats/Resources/ChangeLog.html +++ b/MP.Stats/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

Versione: 6.14.2202.2612

+

Versione: 6.14.2202.2613


Note di rilascio:
    diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt index ce8715a9..b0e6f6ae 100644 --- a/MP.Stats/Resources/VersNum.txt +++ b/MP.Stats/Resources/VersNum.txt @@ -1 +1 @@ -6.14.2202.2612 +6.14.2202.2613 diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml index 445289d3..aa38f9fe 100644 --- a/MP.Stats/Resources/manifest.xml +++ b/MP.Stats/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.14.2202.2612 + 6.14.2202.2613 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