OK grafico linea non stepped
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
@using MP.Data
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<canvas id="@Id"></canvas>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public string Id { get; set; } = "MyTs";
|
||||
|
||||
[Parameter]
|
||||
public List<chartJsData.chartJsTSerie> DataTS { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public string lineColor { get; set; } = "";
|
||||
[Parameter]
|
||||
public string backColor { get; set; } = "";
|
||||
[Parameter]
|
||||
public int lTens { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
/// <param name="firstRender"></param>
|
||||
/// <returns></returns>
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
//if (!firstRender)
|
||||
//{
|
||||
await renderChart();
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
/// <param name="firstRender"></param>
|
||||
/// <returns></returns>
|
||||
protected async Task renderChart()
|
||||
{
|
||||
// creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js
|
||||
var config = new
|
||||
{
|
||||
type = "line",
|
||||
options = new
|
||||
{
|
||||
responsive = true,
|
||||
scales = new
|
||||
{
|
||||
yAxes = new
|
||||
{
|
||||
display = true,
|
||||
ticks = new
|
||||
{
|
||||
maxTicksLimit = 10
|
||||
}
|
||||
},
|
||||
xAxes = new
|
||||
{
|
||||
type = "timeseries",
|
||||
distribution = "linear",
|
||||
}
|
||||
}
|
||||
},
|
||||
data = new
|
||||
{
|
||||
datasets = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
data = DataTS,
|
||||
borderColor= lineColor,
|
||||
backgroundColor= backColor,
|
||||
lineTension= lTens,
|
||||
stepped= false,
|
||||
label= "Temperatura Rilevata"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
await JSRuntime.InvokeVoidAsync("setup", Id, config);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,10 @@
|
||||
<label class="input-group-text">std dev</label>
|
||||
</div>
|
||||
<input class="form-control form-control-sm" @bind="@stdDev" placeholder="deviazione standard" type="number" />
|
||||
<div class="input-group-prepend">
|
||||
<label class="input-group-text">Tensione linea</label>
|
||||
</div>
|
||||
<input class="form-control form-control-sm" @bind="@lineTens" placeholder="deviazione standard" type="number" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-info btn-sm" @onclick="@(async () => await HandleRedraw())">Redraw</button>
|
||||
</div>
|
||||
@@ -32,16 +36,7 @@
|
||||
|
||||
<div class="row">
|
||||
@*<div class="col-3">
|
||||
<LineChart @ref="lineChart" TItem="double" OptionsObject="horizontalLineChartOptions" />
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<PieChart @ref="pieChart" TItem="double" OptionsObject="horizontalLineChartOptions" />
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<HorizontalBarChart @ref="barChartHoriz" TItem="double" OptionsObject="horizontalLineChartOptions" />
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<BarChart @ref="barChart" TItem="double" OptionsObject="horizontalLineChartOptions" />
|
||||
</div>*@
|
||||
<div class="col-6">
|
||||
<BarPlot Id="TestBar" Data="@histGroupData" Labels="@histGroupLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)" Legenda="Freq. Osservate"></BarPlot>
|
||||
@@ -52,5 +47,8 @@
|
||||
<div class="col-6">
|
||||
<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 class="col-6">
|
||||
<Line Id="TestLineTS" DataTS="@dataList" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.3)" lTens="@lineTens"></Line>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -65,11 +65,10 @@ namespace MP.Stats.Pages
|
||||
}
|
||||
}
|
||||
|
||||
protected int lineTens { get; set; } = 0;
|
||||
|
||||
#if false
|
||||
PieChart<double> pieChart;
|
||||
LineChart<double> lineChart;
|
||||
HorizontalBarChart<double> barChartHoriz;
|
||||
BarChart<double> barChart;
|
||||
#endif
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
@@ -176,6 +175,8 @@ namespace MP.Stats.Pages
|
||||
protected string[]? histGroupData { get; set; } = null;
|
||||
|
||||
protected string[]? histGroupLabel { get; set; } = null;
|
||||
|
||||
|
||||
protected List<chartJsData.chartJsTSerie>? dataList { get; set; } = null;
|
||||
#if false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user