From edb7dfda8ad332ca379a05e185aa25cfd0180c8b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 11 Mar 2022 18:08:12 +0100 Subject: [PATCH] Salvataggio di TUTTI i valori da plottare --- MP.MONO.UI/Components/ParamPlot.razor | 8 ---- MP.MONO.UI/Components/ParamPlot.razor.cs | 61 +++++++++++++++++++----- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/MP.MONO.UI/Components/ParamPlot.razor b/MP.MONO.UI/Components/ParamPlot.razor index 4db4a56..d26a4d1 100644 --- a/MP.MONO.UI/Components/ParamPlot.razor +++ b/MP.MONO.UI/Components/ParamPlot.razor @@ -30,16 +30,8 @@ Sample Sec Time - } - - @*@if (showParam) - { -
- Num Val Sample sec time -
- }*@
diff --git a/MP.MONO.UI/Components/ParamPlot.razor.cs b/MP.MONO.UI/Components/ParamPlot.razor.cs index 8bb43a5..4006a25 100644 --- a/MP.MONO.UI/Components/ParamPlot.razor.cs +++ b/MP.MONO.UI/Components/ParamPlot.razor.cs @@ -17,8 +17,14 @@ namespace MP.MONO.UI.Components #region Protected Fields protected DateTime lastRec = DateTime.Now.AddMinutes(-1); - protected List LevelVal = new List(); - protected int sampleSecMin = 1; + + protected Dictionary> plotData = new Dictionary>(); + + protected List LevelVal + { + get => plotData[SelectedParam] ?? new List(); + } + protected double sampleSecMin = 1; #endregion Protected Fields @@ -28,13 +34,6 @@ namespace MP.MONO.UI.Components #endregion Private Properties - //protected string cssSel(string ParamName) - //{ - // string answ = ParamName == SelVal ? "fa-solid fa-chevron-right" : ""; - // return answ; - - //} - #region Protected Properties protected string _selParam { get; set; } = ""; @@ -43,6 +42,10 @@ namespace MP.MONO.UI.Components protected string? MinVal { get; set; } = null; + protected Dictionary listMinVal = new Dictionary(); + protected Dictionary listMaxVal = new Dictionary(); + + #endregion Protected Properties #region Public Properties @@ -61,8 +64,11 @@ namespace MP.MONO.UI.Components { // salvo _selParam = value; - // resetto TimeSerie - LevelVal = new List(); + // cerco se ho in dictionary... + if (!plotData.ContainsKey(value)) + { + plotData.Add(value, new List()); + } } } } @@ -86,6 +92,36 @@ namespace MP.MONO.UI.Components // prendo SOLO il dato della TS richiesta if (ListRecords != null) { + // accodo in blocco tutti i valori... + foreach (var item in ListRecords) + { + // cerco se ci sono min/max del valore indicato... + if (!listMinVal.ContainsKey(item.Title)) + { + listMinVal.Add(item.Title, $"{item.MinVal:N0}"); + } + if (!listMaxVal.ContainsKey(item.Title)) + { + listMaxVal.Add(item.Title, $"{item.MaxVal:N0}"); + } + // verifico dictionary se mancasse... + if (!plotData.ContainsKey(item.Title)) + { + plotData.Add(item.Title, new List()); + } + // ora accodo il valore + + if (plotData.ContainsKey(item.Title)) + { + plotData[item.Title].Add(new chartJsData.chartJsTSerie() { x = adesso, y = item.ValueNum }); + // verifico limite visualizzazione + if (plotData[item.Title].Count > maxRecord) + { + plotData[item.Title].RemoveRange(0, plotData[item.Title].Count - maxRecord); + } + } + } +#if false var newData = ListRecords.Where(x => x.Title == SelectedParam).FirstOrDefault(); // lo accodo if (newData != null) @@ -100,7 +136,8 @@ namespace MP.MONO.UI.Components { LevelVal.RemoveRange(0, LevelVal.Count - maxRecord); } - } + } +#endif } } catch