Fix memoria selezione charts

This commit is contained in:
Samuele Locatelli
2025-07-08 18:37:35 +02:00
parent a9ac59cee4
commit 4e42e8e03a
22 changed files with 106 additions and 102 deletions
+1 -2
View File
@@ -1,5 +1,4 @@
@using ChartJs
<div class="row">
@if (RawData == null || RawData.Count == 0)
{
+5 -6
View File
@@ -49,7 +49,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> bgColors
{
@@ -59,7 +58,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColor
{
@@ -67,9 +65,8 @@ namespace MP.Stats.Components
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// Genera colori linee 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColors
{
@@ -132,9 +129,11 @@ namespace MP.Stats.Components
#region Protected Methods
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> semaphColors(int numRecords, string alpha)
{
@@ -147,9 +146,9 @@ namespace MP.Stats.Components
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// Genera colori bordo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> solidColors(string alpha)
{
+2 -2
View File
@@ -39,11 +39,11 @@
<div class="col-10">
@if (DynMode)
{
<MultiLine Id="PlotODL" AspRatio="4" DataTSList="@TSDataMulti" Labels="@LabelPlot" lineColor="@lineColors" backColor="@bgColors" lTens="0" Titles="@lineTitles" Stepped="false"></MultiLine>
<MultiLine Id="PlotOdlEnergy" AspRatio="4" DataTSList="@TSDataMulti" Labels="@LabelPlot" lineColor="@lineColors" backColor="@bgColors" lTens="0" Titles="@lineTitles" Stepped="false"></MultiLine>
}
else
{
<Line Id="PlotODL" AspRatio="4" DataTS="@DatiPlot" Labels="@LabelPlot" lineColor="@lineColor" backColor="@lineColor" lTens="0" Title="@lineTitles.FirstOrDefault()" Stepped="true"></Line>
<Line Id="PlotOdlEnergy" AspRatio="4" DataTS="@DatiPlot" Labels="@LabelPlot" lineColor="@lineColor" backColor="@lineColor" lTens="0" Title="@lineTitles.FirstOrDefault()" Stepped="true"></Line>
}
</div>
</div>
+16 -4
View File
@@ -14,7 +14,20 @@ namespace MP.Stats.Components
#region Public Properties
[Parameter]
public bool DynMode { get; set; } = false;
public bool DynMode
{
get => _dynMode;
set
{
// salvo valori
if (_dynMode != value)
{
_dynMode = value;
// ricalcolo charting data
RecalcData();
}
}
}
[Parameter]
public EventCallback<string> EC_IdxMaccRem { get; set; }
@@ -46,7 +59,6 @@ namespace MP.Stats.Components
#region Protected Properties
protected SelectData _currFilter { get; set; } = new SelectData();
protected List<MP.Data.DbModels.OdlEnergyModel> _rawData { get; set; } = new List<MP.Data.DbModels.OdlEnergyModel>();
/// <summary>
@@ -129,15 +141,15 @@ namespace MP.Stats.Components
#region Private Fields
private List<string> lineTitles = new List<string>() { "Consumo/UM" };
private List<string> listMachine = new List<string>();
private string pieTitle = "Macchina";
#endregion Private Fields
#region Private Properties
private bool _dynMode { get; set; } = false;
private List<double> DatiPareto
{
get => ParetoData.Select(x => x.value).ToList();
+5
View File
@@ -54,6 +54,11 @@
await renderChart();
}
protected override async Task OnParametersSetAsync()
{
await renderChart();
}
/// <summary>
/// Inizializzazione rendering componente
///
+1 -2
View File
@@ -1,5 +1,4 @@
@using ChartJs
<div class="row">
@if (RawData == null || RawData.Count == 0)
{
+2 -4
View File
@@ -42,7 +42,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> bgColors
{
@@ -52,7 +51,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColor
{
@@ -62,7 +60,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColors
{
@@ -143,6 +140,7 @@ namespace MP.Stats.Components
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> semaphColors(int numRecords, string alpha)
{
@@ -168,7 +166,7 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> solidColors(string alpha)
{
+1 -2
View File
@@ -1,5 +1,4 @@
@using ChartJs
<div class="row">
@if (RawData == null || RawData.Count == 0)
{
+5 -6
View File
@@ -41,7 +41,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> bgColors
{
@@ -51,7 +50,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColor
{
@@ -59,9 +57,8 @@ namespace MP.Stats.Components
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// Genera colori linea 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColors
{
@@ -124,9 +121,11 @@ namespace MP.Stats.Components
#region Protected Methods
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> semaphColors(int numRecords, string alpha)
{
@@ -150,9 +149,9 @@ namespace MP.Stats.Components
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// Genera colori bordo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> solidColors(string alpha)
{
+3 -4
View File
@@ -1,5 +1,4 @@
@using ChartJs
<div class="row">
<div class="col-2">
<div class="card shadow">
@@ -66,11 +65,11 @@
<div class="text-center">
<b>@pSel</b> Detail
</div>
<MultiLine Id="plotDetail" AspRatio="4" DataTSList="@TSDataMultiDetail" Labels="@LabelPlotDet" lineColor="@lineColorsDet" backColor="@bgColorsDet" lTens="0" Titles="@lineTitlesDet" Stepped="false"></MultiLine>
<MultiLine Id="TrendPlotDetail" AspRatio="4" DataTSList="@TSDataMultiDetail" Labels="@LabelPlotDet" lineColor="@lineColorsDet" backColor="@bgColorsDet" lTens="0" Titles="@lineTitlesDet" Stepped="false"></MultiLine>
<div class="text-center">
<b>Periodo</b>
</div>
<MultiLine Id="plotAll" AspRatio="4" DataTSList="@TSDataMulti" Labels="@LabelPlot" lineColor="@lineColors" backColor="@bgColors" lTens="0" Titles="@lineTitles" Stepped="false"></MultiLine>
<MultiLine Id="TrendPlotAll" AspRatio="4" DataTSList="@TSDataMulti" Labels="@LabelPlot" lineColor="@lineColors" backColor="@bgColors" lTens="0" Titles="@lineTitles" Stepped="false"></MultiLine>
</div>
</div>
}
+3 -1
View File
@@ -195,7 +195,9 @@ namespace MP.Stats.Components
private List<string> lineTitles = new List<string>() { "Consumo/UM" };
private List<string> lineTitlesDet = new List<string>() { "Consumo/UM" };
private List<string> listMachine = new List<string>();
private string pieTitle = "Macchina";
#if false
private string pieTitle = "Macchina";
#endif
/// <summary>
/// Modalità selezione
+1 -2
View File
@@ -1,5 +1,4 @@
@using ChartJs
<div class="row">
@if (RawData == null || RawData.Count == 0)
{
+4 -5
View File
@@ -49,7 +49,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> bgColors
{
@@ -59,7 +58,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColor
{
@@ -69,7 +67,6 @@ namespace MP.Stats.Components
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColors
{
@@ -138,9 +135,11 @@ namespace MP.Stats.Components
#region Protected Methods
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> semaphColors(int numRecords, string alpha)
{
@@ -164,9 +163,9 @@ namespace MP.Stats.Components
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// Genera colori bordo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <param name="alpha"></param>
/// <returns></returns>
protected List<string> solidColors(string alpha)
{
+2
View File
@@ -54,6 +54,8 @@ namespace MP.Stats.Data
public SelectData KRE_Filter { get; set; } = SelectData.Init(5, 7);
public SelectData ODL_Filter { get; set; } = SelectData.Init(5, 7);
public SelectData EnergyOdl_Filter { get; set; } = SelectData.Init(5, 7);
public SelectData EnergyTrend_Filter { get; set; } = SelectData.Init(5, 7);
public SelectData OEE_Filter { get; set; } = SelectData.Init(5, 7);
public string PageIcon
+2 -2
View File
@@ -4,8 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Stats</RootNamespace>
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
<Version>6.16.2507.0809</Version>
<Version>6.16.2507.0809</Version>
<Version>6.16.2507.0818</Version>
<Version>6.16.2507.0818</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
+4 -9
View File
@@ -1,10 +1,8 @@
@page "/Energy"
@using MP.Stats.Components
<div class="card">
<div class="card-header table-primary p-1">
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter" chartVisible="ShowCharts" chartsToggle="ToggleChart" ChartEnabled="true" OnlyEnergy="true" MaxNumMacc="MaxDisplay" SelMultiMacc="true"></SelectionFilter>
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter" ChartEnabled="false" OnlyEnergy="true" MaxNumMacc="MaxDisplay" SelMultiMacc="true"></SelectionFilter>
</div>
<div class="card-body py-0 px-1">
@if (isLoading)
@@ -15,10 +13,6 @@
{
if (MaccSelValid)
{
if (ShowCharts == true)
{
<ChartEnergy RawData="SearchRecords" DynMode="dynMode" HideCurrent="true" ShowRem="true" EC_IdxMaccRem="RemoveMachine"></ChartEnergy>
}
@if (ListRecords == null)
{
<LoadingData></LoadingData>
@@ -29,6 +23,7 @@
}
else
{
<ChartEnergy RawData="SearchRecords" DynMode="DynMode" HideCurrent="true" ShowRem="true" EC_IdxMaccRem="RemoveMachine"></ChartEnergy>
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
@@ -39,7 +34,7 @@
<th>Articolo</th>
<th>Inizio</th>
<th>Fine</th>
@if (dynMode)
@if (DynMode)
{
<th class="text-end">@Traduci("MP-STATS_TotCount01")</th>
@if (numCount > 1)
@@ -87,7 +82,7 @@
</td>
<td class="@textCss">@record.DataInizio</td>
<td class="@textCss">@record.DataFine</td>
@if (dynMode)
@if (DynMode)
{
<td class="text-end @textCss">@($"{record.TotCount01:N0}") @GetUM("TotCount01")</td>
@if (numCount > 1)
+16 -23
View File
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DbModels;
using MP.Data.Services;
using MP.Stats.Components;
using MP.Stats.Data;
using System;
using System.Collections.Generic;
@@ -18,6 +19,8 @@ namespace MP.Stats.Pages
public void Dispose()
{
MServ.EA_SearchUpdated -= OnSeachUpdated;
ListRecords.Clear();
SearchRecords.Clear();
}
public async void OnSeachUpdated()
@@ -47,7 +50,7 @@ namespace MP.Stats.Pages
protected IJSRuntime JSRuntime { get; set; }
/// <summary>
/// Verifica validità selezione macchine
/// Verifica validit selezione macchine
/// </summary>
protected bool MaccSelValid
{
@@ -71,7 +74,7 @@ namespace MP.Stats.Pages
#region Protected Methods
/// <summary>
/// Verifica: se è nullo il valore pz totali --> current --> indico non confermato
/// Verifica: se nullo il valore pz totali --> current --> indico non confermato
/// </summary>
/// <param name="testRec"></param>
/// <returns></returns>
@@ -112,14 +115,15 @@ namespace MP.Stats.Pages
protected override async Task OnInitializedAsync()
{
isLoading = true;
clearFile();
numRecord = 10;
MServ.ShowSearch = false;
MServ.PageName = "ENERGY";
MServ.PageIcon = "oi oi-bar-chart";
MServ.EA_SearchUpdated += OnSeachUpdated;
await LoadConfData();
await ReloadData();
isLoading = false;
}
protected void ResetData()
@@ -161,14 +165,6 @@ namespace MP.Stats.Pages
DisplayData();
}
protected async Task ToggleChart(bool doShow)
{
ShowCharts = !ShowCharts;
if (ShowCharts)
{
await ReloadData();
}
}
/// <summary>
/// Traduzione lemma richeisto (lingua default="IT")
@@ -193,7 +189,7 @@ namespace MP.Stats.Pages
private List<ConfigModel> ConfigList;
private OdlEnergyModel currRecord = null;
private bool dynMode = false;
private bool DynMode = true;
private List<OdlEnergyModel> ListRecords;
private int MaxDisplay = 20;
private int numCount = 1;
@@ -208,11 +204,11 @@ namespace MP.Stats.Pages
{
get
{
return MServ.ODL_Filter;
return MServ.EnergyOdl_Filter;
}
set
{
MServ.ODL_Filter = value;
MServ.EnergyOdl_Filter = value;
}
}
@@ -225,7 +221,6 @@ namespace MP.Stats.Pages
private bool isLoading { get; set; } = false;
private int numRecord { get; set; } = 10;
private bool ShowCharts { get; set; } = true;
#endregion Private Properties
@@ -270,11 +265,11 @@ namespace MP.Stats.Pages
private async Task LoadConfData()
{
isLoading = true;
ConfigList = await StatService.ConfigGetAll();
ListMacchine = await StatService.MachineList(true);
NumMacc = ListMacchine.Count();
dynMode = confVal("STATS_EnergyMode") == "Dynamic";
var sNumCount = confVal("STATS_EnergyNumCount");
DynMode = confVal("STATS_EnergyMode") == "Dynamic";
int.TryParse(confVal("STATS_EnergyNumCount"), out numCount);
int.TryParse(confVal("STATS_EnergyNumTotEn"), out numTotEn);
int.TryParse(confVal("STATS_EnergyMaxSelect"), out MaxDisplay);
@@ -282,6 +277,7 @@ namespace MP.Stats.Pages
private async Task ReloadData()
{
isLoading = true;
if (SearchRecords != null)
{
SearchRecords.Clear();
@@ -291,11 +287,7 @@ namespace MP.Stats.Pages
SearchRecords = new List<OdlEnergyModel>();
}
// se seleziona tutte...
if (currFilter.ListIdxMaccSel == null || currFilter.ListIdxMaccSel.Count == 0)
{
SearchRecords = await StatService.StatOdlEnergyGetAll(currFilter, MServ.SearchVal);
}
else
if (currFilter.ListIdxMaccSel != null && currFilter.ListIdxMaccSel.Count > 0)
{
foreach (var idxMacc in currFilter.ListIdxMaccSel)
{
@@ -307,6 +299,7 @@ namespace MP.Stats.Pages
}
TotalCount = SearchRecords.Count;
DisplayData();
isLoading = false;
}
/// <summary>
@@ -315,7 +308,7 @@ namespace MP.Stats.Pages
/// <param name="idxMacc"></param>
private async Task RemoveMachine(string idxMacc)
{
// in primis se contiene spazio --> prendo prima aprte che è idxMacc...
// in primis se contiene spazio --> prendo prima aprte che idxMacc...
if (idxMacc.Contains(" "))
{
var sVals = idxMacc.Split(' ');
-1
View File
@@ -1,7 +1,6 @@
@page "/TrendAnalysis"
@page "/trend-analysis"
@using MP.Stats.Components
<div class="card">
<div class="card-header table-primary p-1">
+30 -24
View File
@@ -1,13 +1,11 @@
using DnsClient.Protocol;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DbModels;
using MP.Data.Services;
using MP.Stats.Data;
using NLog.Config;
using Org.BouncyCastle.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -40,6 +38,7 @@ namespace MP.Stats.Pages
protected string CodFluxSel = "*";
protected string fileName = "TrendAnalysis.csv";
protected List<AutocompleteModel> ListMacchine = new List<AutocompleteModel>();
protected int SelCount = 0;
protected int TotalCount = 0;
@@ -158,7 +157,6 @@ namespace MP.Stats.Pages
MServ.ShowSearch = false;
MServ.PageName = "Trend Analisys";
MServ.PageIcon = "fa-solid fa-arrow-trend-up";
CalcFilt();
MServ.EA_SearchUpdated += OnSeachUpdated;
await LoadConfData();
await ReloadData();
@@ -167,8 +165,13 @@ namespace MP.Stats.Pages
protected async Task ResetFilter(SelectData newFilter)
{
#if false
SearchRecords = null;
CalcFilt();
CalcFilt();
#endif
SearchRecords = null;
PlotRecords = null;
currFilter = SelectData.Init(5, 7);
await ReloadData();
}
@@ -223,11 +226,11 @@ namespace MP.Stats.Pages
{
get
{
return MServ.ODL_Filter;
return MServ.EnergyTrend_Filter;
}
set
{
MServ.ODL_Filter = value;
MServ.EnergyTrend_Filter = value;
}
}
@@ -237,6 +240,7 @@ namespace MP.Stats.Pages
#region Private Methods
#if false
/// <summary>
/// Calcola il filtro alla data necessaria x arrivare al confronto x mese...
/// </summary>
@@ -246,6 +250,21 @@ namespace MP.Stats.Pages
DateTime inizio = new DateTime(oggi.Year, oggi.Month, 1).AddMonths(-1);
int numPrev = (int)oggi.Subtract(inizio).TotalDays;
currFilter = SelectData.Init(5, numPrev);
}
#endif
private string confVal(string chiave)
{
string answ = "";
if (ConfigList != null && ConfigList.Count > 0)
{
var searchRec = ConfigList.First(x => x.Chiave == chiave);
if (searchRec != null)
{
answ = searchRec.Valore;
}
}
return answ;
}
/// <summary>
@@ -291,21 +310,6 @@ namespace MP.Stats.Pages
CodFluxList = await StatService.FluxTypeList();
ListMacchine = await StatService.MachineList(true);
}
private string confVal(string chiave)
{
string answ = "";
if (ConfigList != null && ConfigList.Count > 0)
{
var searchRec = ConfigList.First(x => x.Chiave == chiave);
if (searchRec != null)
{
answ = searchRec.Valore;
}
}
return answ;
}
protected List<AutocompleteModel> ListMacchine = new List<AutocompleteModel>();
private async Task ReloadData()
{
@@ -314,14 +318,15 @@ namespace MP.Stats.Pages
// ciclo caricando info x ogni macchina selezionata...
if (SearchRecords != null)
{
SearchRecords.Clear();// = new Dictionary<string, List<FLModel>>();
SearchRecords.Clear();
}
else
{
SearchRecords = new Dictionary<string, List<FLModel>>();
}
if (currFilter.ListIdxMaccSel.Count > 0)
if (currFilter.ListIdxMaccSel != null && currFilter.ListIdxMaccSel.Count > 0)
{
var lastIdx = currFilter.IdxMacchina;
foreach (var idxMacc in currFilter.ListIdxMaccSel)
{
currFilter.IdxMacchina = idxMacc;
@@ -329,6 +334,7 @@ namespace MP.Stats.Pages
SearchRecords.Add(idxMacc, tempRec);
tempRec = null;
}
currFilter.IdxMacchina = lastIdx;
}
TotalCount = SearchRecords.Count;
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo statistiche MAPO</i>
<h4>Versione: 6.16.2507.0809</h4>
<h4>Versione: 6.16.2507.0818</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2507.0809
6.16.2507.0818
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2507.0809</version>
<version>6.16.2507.0818</version>
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>