Spostamento org classi chartJs + nuova opzione horiz chart

This commit is contained in:
Samuele Locatelli
2022-02-24 12:09:33 +01:00
parent b760d4fa1a
commit d6c226ae1a
9 changed files with 65 additions and 15 deletions
@@ -14,9 +14,9 @@ using Microsoft.JSInterop;
using MP.Stats;
using MP.Stats.Shared;
namespace MP.Stats.Components
namespace MP.Stats.Components.ChartJs
{
public partial class ChartJsBar
public partial class BarPlot
{
[Inject]
IJSRuntime JSRuntime { get; set; }
@@ -26,6 +26,9 @@ namespace MP.Stats.Components
[Parameter]
public string Legenda { get; set; } = "Legenda";
[Parameter]
public bool Horizontal { get; set; } = false;
[Parameter]
public string[]? Data { get; set; }
@@ -44,6 +47,7 @@ namespace MP.Stats.Components
//}
}
/// <summary>
/// Inizializzazione rendering componente
///
@@ -56,7 +60,7 @@ namespace MP.Stats.Components
/// <returns></returns>
protected async Task renderChart()
{
// creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js
// creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js, tipo verticale
var config = new
{
type = "bar",
@@ -81,17 +85,60 @@ namespace MP.Stats.Components
{
datasets = new[] {
new {
data = Data,
borderColor = lineColor,
backgroundColor = backColor,
borderWidth = 1,
data = Data,
borderColor = lineColor,
backgroundColor = backColor,
borderWidth = 1,
label = Legenda
}
},
labels = Labels
}
};
await JSRuntime.InvokeVoidAsync("setup", Id, config);
// creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js, tipo verticale
var configHor = new
{
type = "bar",
options = new
{
indexAxis = "y",
responsive = true,
scales = new
{
yAxes = new
{
suggestedMin = 0,
display = true,
ticks = new
{
beginAtZero = true,
maxTicksLimit = 10
}
}
}
},
data = new
{
datasets = new[] {
new {
data = Data,
borderColor = lineColor,
backgroundColor = backColor,
borderWidth = 1,
label = Legenda
}
},
labels = Labels
}
};
if (Horizontal)
{
await JSRuntime.InvokeVoidAsync("setup", Id, configHor);
}
else
{
await JSRuntime.InvokeVoidAsync("setup", Id, config);
}
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Stats</RootNamespace>
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
<Version>6.14.2202.2217</Version>
<Version>6.14.2202.2412</Version>
</PropertyGroup>
<ItemGroup>
+6 -3
View File
@@ -1,6 +1,6 @@
@page "/test"
@using MP.Stats.Components
@using MP.Stats.Components.ChartJs
<h1>Test Normal plot</h1>
@@ -44,10 +44,13 @@
<BarChart @ref="barChart" TItem="double" OptionsObject="horizontalLineChartOptions" />
</div>*@
<div class="col-6">
<ChartJsBar Id="TestBar" Data="@histData" Labels="@histLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)" Legenda="Freq. Osservate"></ChartJsBar>
<BarPlot Id="TestBar" Data="@histData" Labels="@histLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)" Legenda="Freq. Osservate"></BarPlot>
</div>
<div class="col-6">
<ChartJsStepLine Id="TestTS" DataTS="@dataList" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.3)"></ChartJsStepLine>
<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>
</div>
</div>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo statistiche MAPO</i>
<h4>Versione: 6.14.2202.2217</h4>
<h4>Versione: 6.14.2202.2412</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.14.2202.2217
6.14.2202.2412
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.14.2202.2217</version>
<version>6.14.2202.2412</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>