diff --git a/MP.Stats/Components/ChartJs/PieChart.razor b/MP.Stats/Components/ChartJs/PieChart.razor
new file mode 100644
index 00000000..b792e394
--- /dev/null
+++ b/MP.Stats/Components/ChartJs/PieChart.razor
@@ -0,0 +1,87 @@
+@using MP.Data
+@inject IJSRuntime JSRuntime
+
+
+
+@code {
+
+ [Parameter]
+ public string Id { get; set; } = "MyTs";
+
+ [Parameter]
+ public List Data { get; set; } = null!;
+
+ [Parameter]
+ public string lineColor { get; set; } = "";
+ [Parameter]
+ public string backColor { get; set; } = "";
+ [Parameter]
+ public int lTens { get; set; } = 0;
+
+ ///
+ /// Inizializzazione rendering componente
+ ///
+ /// partendo da qui:
+ /// https://www.williamleme.com/posts/2020/003-chartjs-blazor/
+ /// https://www.puresourcecode.com/dotnet/blazor/using-chart-js-with-blazor/
+ /// https://www.tutorialsteacher.com/csharp/csharp-anonymous-type
+ ///
+ ///
+ ///
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ //if (!firstRender)
+ //{
+ await renderChart();
+ //}
+ }
+
+ ///
+ /// Inizializzazione rendering componente
+ ///
+ /// partendo da qui:
+ /// https://www.williamleme.com/posts/2020/003-chartjs-blazor/
+ /// https://www.puresourcecode.com/dotnet/blazor/using-chart-js-with-blazor/
+ /// https://www.tutorialsteacher.com/csharp/csharp-anonymous-type
+ ///
+ ///
+ ///
+ protected async Task renderChart()
+ {
+ // creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js
+ var config = new
+ {
+ type = "pie",
+ options = new
+ {
+ responsive = true,
+ // plugins = {
+ // legend =
+ // {
+ // position = "top",
+ // },
+ // title = {
+ // display = true,
+ // text = 'Chart.js Pie Chart'
+ // }
+ //}
+ },
+ data = new
+ {
+ datasets = new[]
+ {
+ new
+ {
+ data = Data,
+ borderColor= lineColor,
+ backgroundColor= backColor,
+ lineTension= lTens,
+ stepped= false,
+ label= "Temperatura Rilevata"
+ }
+}
+ }
+ };
+ await JSRuntime.InvokeVoidAsync("setup", Id, config);
+ }
+}
\ No newline at end of file
diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj
index ed929293..4253468b 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.2511
+ 6.14.2202.2512
diff --git a/MP.Stats/Pages/Test.razor b/MP.Stats/Pages/Test.razor
index f1c8c388..c2d76c75 100644
--- a/MP.Stats/Pages/Test.razor
+++ b/MP.Stats/Pages/Test.razor
@@ -50,5 +50,8 @@
+
diff --git a/MP.Stats/Pages/Test.razor.cs b/MP.Stats/Pages/Test.razor.cs
index 0631976e..a9cdc253 100644
--- a/MP.Stats/Pages/Test.razor.cs
+++ b/MP.Stats/Pages/Test.razor.cs
@@ -132,16 +132,10 @@ namespace MP.Stats.Pages
#if false
await pieChart.Clear();
await pieChart.AddLabelsDatasetsAndUpdate(Labels, GetPieChartDataset());
- await lineChart.Clear();
- await lineChart.AddLabelsDatasetsAndUpdate(Labels, GetLineChartDataset());
- await barChart.Clear();
- await barChart.AddLabelsDatasetsAndUpdate(Labels, GetBarChartDataset());
- await barChartHoriz.Clear();
- await barChartHoriz.AddLabelsDatasetsAndUpdate(Labels, GetHorizBarChartDataset());
#endif
// calcolo hist frequenza con EFCore: https://entityframeworkcore.com/knowledge-base/60871048/group-by-and-to-dictionary-in-ef-core-3-1
- var rawData = RandomizeData();
- var histDict = rawData.GroupBy(r => r).Select(g => new
+ randData = RandomizeData();
+ var histDict = randData.GroupBy(r => r).Select(g => new
{
g.Key,
Count = g.Count()
@@ -151,10 +145,10 @@ namespace MP.Stats.Pages
// calcolo i valori raggruppati in numGroup...
int numGroup = (int)Math.Sqrt(numRec);
- double minVal = rawData.Min();
- double maxVal = rawData.Max();
+ double minVal = randData.Min();
+ double maxVal = randData.Max();
double step = (maxVal - minVal) / numGroup;
- var histDictGroup = rawData.GroupBy(r => ((int)Math.Round((r - minVal) / step)) * step + minVal).Select(g => new
+ var histDictGroup = randData.GroupBy(r => ((int)Math.Round((r - minVal) / step)) * step + minVal).Select(g => new
{
g.Key,
Count = g.Count()
@@ -164,7 +158,7 @@ namespace MP.Stats.Pages
- dataList = TSData(DateTime.Today.AddHours(-rawData.Count), rawData).Select(r => new chartJsData.chartJsTSerie()
+ dataList = TSData(DateTime.Today.AddHours(-randData.Count), randData).Select(r => new chartJsData.chartJsTSerie()
{ x = r.Key, y = r.Value }).ToList();
}
@@ -176,6 +170,8 @@ namespace MP.Stats.Pages
protected string[]? histGroupLabel { get; set; } = null;
+ protected List randData { get; set; } = new List();
+
protected List? dataList { get; set; } = null;
#if false
diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html
index 00e3c255..84485819 100644
--- a/MP.Stats/Resources/ChangeLog.html
+++ b/MP.Stats/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo statistiche MAPO
- Versione: 6.14.2202.2511
+ Versione: 6.14.2202.2512
Note di rilascio:
diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt
index 47a106c9..bd6c22d1 100644
--- a/MP.Stats/Resources/VersNum.txt
+++ b/MP.Stats/Resources/VersNum.txt
@@ -1 +1 @@
-6.14.2202.2511
+6.14.2202.2512
diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml
index 94cd6606..c23d66ac 100644
--- a/MP.Stats/Resources/manifest.xml
+++ b/MP.Stats/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.14.2202.2511
+ 6.14.2202.2512
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