Fix bar plot vert/horiuz + freq hist test
This commit is contained in:
@@ -11,7 +11,7 @@ namespace MP.Data
|
||||
#region Public Properties
|
||||
|
||||
public DateTime x { get; set; }
|
||||
public decimal y { get; set; }
|
||||
public double y { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
@@ -20,8 +20,8 @@ namespace MP.Data
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public decimal x { get; set; }
|
||||
public decimal y { get; set; }
|
||||
public double x { get; set; }
|
||||
public double y { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>MP.Stats</RootNamespace>
|
||||
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
|
||||
<Version>6.14.2202.2412</Version>
|
||||
<Version>6.14.2202.2511</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
<div class="input-group-prepend">
|
||||
<label class="input-group-text"># punti</label>
|
||||
</div>
|
||||
<input class="form-control form-control-sm" @bind="@numRec" placeholder="# punti da simulare" />
|
||||
<input class="form-control form-control-sm" @bind="@numRec" placeholder="# punti da simulare" type="number" />
|
||||
<div class="input-group-prepend">
|
||||
<label class="input-group-text">media</label>
|
||||
</div>
|
||||
<input class="form-control form-control-sm" @bind="@mean" placeholder="valore media" />
|
||||
<input class="form-control form-control-sm" @bind="@mean" placeholder="valore media" type="number" />
|
||||
<div class="input-group-prepend">
|
||||
<label class="input-group-text">std dev</label>
|
||||
</div>
|
||||
<input class="form-control form-control-sm" @bind="@stdDev" placeholder="deviazione standard" />
|
||||
<input class="form-control form-control-sm" @bind="@stdDev" placeholder="deviazione standard" type="number" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-info btn-sm" @onclick="@(async () => await HandleRedraw())">Redraw</button>
|
||||
</div>
|
||||
@@ -44,13 +44,13 @@
|
||||
<BarChart @ref="barChart" TItem="double" OptionsObject="horizontalLineChartOptions" />
|
||||
</div>*@
|
||||
<div class="col-6">
|
||||
<BarPlot Id="TestBar" Data="@histData" Labels="@histLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)" Legenda="Freq. Osservate"></BarPlot>
|
||||
<BarPlot Id="TestBar" Data="@histGroupData" Labels="@histGroupLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)" Legenda="Freq. Osservate"></BarPlot>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<StepLine Id="TestTS" DataTS="@dataList" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.3)"></StepLine>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<BarPlot Id="TestBarHor" Horizontal="true" Data="@histData" Labels="@histLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)" Legenda="Freq. Osservate"></BarPlot>
|
||||
<BarPlot Id="TestBarHor" Horizontal="true" Data="@histGroupData" Labels="@histGroupLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)" Legenda="Freq. Osservate"></BarPlot>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace MP.Stats.Pages
|
||||
|
||||
public int numRec
|
||||
{
|
||||
get { return _numRec;
|
||||
get
|
||||
{
|
||||
return _numRec;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -148,6 +150,20 @@ namespace MP.Stats.Pages
|
||||
histData = histDict.Values.ToArray();
|
||||
histLabel = histDict.Keys.Select(x => $"{x}").ToArray();
|
||||
|
||||
// calcolo i valori raggruppati in numGroup...
|
||||
int numGroup = (int)Math.Sqrt(numRec);
|
||||
double minVal = rawData.Min();
|
||||
double maxVal = rawData.Max();
|
||||
double step = (maxVal - minVal) / numGroup;
|
||||
var histDictGroup = rawData.GroupBy(r => ((int)Math.Round((r - minVal) / step)) * step + minVal).Select(g => new
|
||||
{
|
||||
g.Key,
|
||||
Count = g.Count()
|
||||
}).OrderBy(d => d.Key).ToDictionary(x => x.Key, x => x.Count.ToString());
|
||||
histGroupData = histDictGroup.Values.ToArray();
|
||||
histGroupLabel = histDictGroup.Keys.Select(x => $"{x:N2}").ToArray();
|
||||
|
||||
|
||||
|
||||
dataList = TSData(DateTime.Today.AddHours(-rawData.Count), rawData).Select(r => new chartJsData.chartJsTSerie()
|
||||
{ x = r.Key, y = r.Value }).ToList();
|
||||
@@ -156,6 +172,10 @@ namespace MP.Stats.Pages
|
||||
protected string[]? histData { get; set; } = null;
|
||||
|
||||
protected string[]? histLabel { get; set; } = null;
|
||||
|
||||
protected string[]? histGroupData { get; set; } = null;
|
||||
|
||||
protected string[]? histGroupLabel { get; set; } = null;
|
||||
protected List<chartJsData.chartJsTSerie>? dataList { get; set; } = null;
|
||||
#if false
|
||||
|
||||
@@ -186,12 +206,12 @@ namespace MP.Stats.Pages
|
||||
List<string> borderColors = new List<string> { ChartColor.FromRgba(255, 99, 132, 1f), ChartColor.FromRgba(54, 162, 235, 1f), ChartColor.FromRgba(255, 206, 86, 1f), ChartColor.FromRgba(75, 192, 192, 1f), ChartColor.FromRgba(153, 102, 255, 1f), ChartColor.FromRgba(255, 159, 64, 1f) };
|
||||
#endif
|
||||
|
||||
private List<int> RandomizeData()
|
||||
private List<double> RandomizeData()
|
||||
{
|
||||
var r = new Random(DateTime.Now.Millisecond);
|
||||
|
||||
|
||||
List<int> answ = new List<int>();
|
||||
List<double> answ = new List<double>();
|
||||
for (int i = 0; i < numRec; i++)
|
||||
{
|
||||
double u1 = 1.0 - r.NextDouble(); // uniform (0,1] random doubles
|
||||
@@ -199,14 +219,14 @@ namespace MP.Stats.Pages
|
||||
double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2);
|
||||
double randNormal = mean + stdDev * randStdNormal; // random normal (mean, stdDev^2)
|
||||
//answ.Add(r.Next(3, 30) * r.NextDouble());
|
||||
answ.Add((int)(randNormal * 10));
|
||||
answ.Add(randNormal);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
private Dictionary<DateTime, decimal> TSData(DateTime inizio, List<int> yData)
|
||||
private Dictionary<DateTime, double> TSData(DateTime inizio, List<double> yData)
|
||||
{
|
||||
Dictionary<DateTime, decimal> answ = new Dictionary<DateTime, decimal>();
|
||||
Dictionary<DateTime, double> answ = new Dictionary<DateTime, double>();
|
||||
// usando i dati ricevuti aggiunge variabile x = tempo crescente
|
||||
int idx = 0;
|
||||
foreach (var item in yData)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 6.14.2202.2412</h4>
|
||||
<h4>Versione: 6.14.2202.2511</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.14.2202.2412
|
||||
6.14.2202.2511
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.14.2202.2412</version>
|
||||
<version>6.14.2202.2511</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>
|
||||
|
||||
Reference in New Issue
Block a user