Plot ODL
This commit is contained in:
@@ -6,155 +6,61 @@ namespace MP.SPEC.Components.Chart
|
||||
{
|
||||
public partial class Doughnut
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public double AspRatio { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public List<string> backColor { get; set; } = new List<string>();
|
||||
|
||||
[Parameter]
|
||||
public int ChartId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
set
|
||||
{
|
||||
Id = value;
|
||||
}
|
||||
}
|
||||
|
||||
//[Parameter]
|
||||
//public List<chartJsData.chartJsTSerie> DataTS
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return _DataTS;
|
||||
// }
|
||||
|
||||
// set
|
||||
// {
|
||||
// _DataTS = value;
|
||||
// //var pUpd = Task.Run(async () => await renderChart());
|
||||
// //pUpd.Wait();
|
||||
// }
|
||||
//}
|
||||
|
||||
[Parameter]
|
||||
public List<string> Labels { get; set; } = new List<string>();
|
||||
|
||||
//[Parameter]
|
||||
//public List<string> lineColor { get; set; } = new List<string>();
|
||||
|
||||
[Parameter]
|
||||
public int lTens { get; set; } = 0;
|
||||
|
||||
//[Parameter]
|
||||
//public string MaxValue { get; set; } = "0";
|
||||
|
||||
//[Parameter]
|
||||
//public string MinValue { get; set; } = "0";
|
||||
|
||||
//[Parameter]
|
||||
//public List<string> pointColor { get; set; } = new List<string>();
|
||||
|
||||
[Parameter]
|
||||
public string Title { get; set; } = "Demo Line";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected int Id { get; set; } = 0;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <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)
|
||||
{
|
||||
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 = "doughnut",
|
||||
options = new
|
||||
{
|
||||
responsive = true,
|
||||
//scales = new
|
||||
//{
|
||||
// yAxes = new
|
||||
// {
|
||||
// display = true,
|
||||
// position = "right",
|
||||
// ticks = new
|
||||
// {
|
||||
// maxTicksLimit = 10
|
||||
// }
|
||||
// },
|
||||
// xAxes = new
|
||||
// {
|
||||
// type = "time",
|
||||
// distribution = "linear",
|
||||
// }
|
||||
//},
|
||||
plugins = new
|
||||
{
|
||||
legend = new
|
||||
{
|
||||
display = false
|
||||
},
|
||||
},
|
||||
Animation = false,
|
||||
AspectRatio = AspRatio == 0 ? "auto" : $"{AspRatio}"
|
||||
},
|
||||
data = new
|
||||
{
|
||||
labels = Labels,
|
||||
datasets = new[]{new
|
||||
{
|
||||
data = 300, pointBorderColor = backColor, backgroundColor = backColor, fill = true, PointRadius = 2, BorderWidth = 1, lineTension = lTens, stepped = false, label = Title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
await JSRuntime.InvokeVoidAsync("setup", Id, config);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private List<chartJsData.chartJsTSerie> _DataTS { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
public enum ChartType
|
||||
{
|
||||
Pie,
|
||||
Bar,
|
||||
Doughnut
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public string Id { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public ChartType Type { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public double[] Data { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string[] BackgroundColor { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string[] Labels { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
var config = new
|
||||
{
|
||||
Type = Type.ToString().ToLower(),
|
||||
Options = new
|
||||
{
|
||||
Responsive = true,
|
||||
Scales = new
|
||||
{
|
||||
YAxes = new[]
|
||||
{
|
||||
new { Ticks = new {
|
||||
BeginAtZero=true
|
||||
} }
|
||||
}
|
||||
}
|
||||
},
|
||||
Data = new
|
||||
{
|
||||
Datasets = new[]
|
||||
{
|
||||
new { Data = Data, BackgroundColor = BackgroundColor}
|
||||
},
|
||||
Labels = Labels
|
||||
}
|
||||
};
|
||||
|
||||
await JSRuntime.InvokeVoidAsync("setup", Id, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,27 +87,91 @@ else
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="staticBackdropLabel">Modal title</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="modal-body col-12">
|
||||
@if (currRecord != null)
|
||||
{
|
||||
<h3>ODL @currRecord.IdxOdl</h3>
|
||||
@if (ListOdlStats != null)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var statRecord in ListOdlStats)
|
||||
{
|
||||
<li>@statRecord.Descrizione - @($"{statRecord.TotDurata:N1}min")</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="col-6">
|
||||
<div>
|
||||
<table class="table table-sm" style="max-width:500px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><i class="fa-solid fa-file"></i> Articolo</th>
|
||||
<th><i class="fa-solid fa-file"></i> Descrizione Art.</th>
|
||||
<th><i class="fa-solid fa-screwdriver-wrench"></i> Fase</th>
|
||||
<th><i class="fa-solid fa-screwdriver-wrench"></i> Note</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>@currRecord.CodArticolo</th>
|
||||
<td>@currRecord.ArticoloNav.DescArticolo</td>
|
||||
<td>@currRecord.KeyRichiesta</td>
|
||||
<td>@currRecord.Note</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<table class="table table-sm" style="max-width:500px;">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th><i class="fa-solid fa-hard-drive"></i> Macchina</th>
|
||||
<th><i class="fa-solid fa-hard-drive"></i> Info macchina</th>
|
||||
<th><i class="fa-solid fa-calendar-day"></i> Periodo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
|
||||
<td>@currRecord.IdxMacchina</td>
|
||||
<td>@currRecord.MachineNav.CodMacchina</td>
|
||||
<td>
|
||||
<div class="small d-flex justify-content-between">
|
||||
<div>
|
||||
<div><b>@($"{@record.DataInizio:yyyy/MM/dd}")</b></div>
|
||||
<div>@($"{@record.DataInizio:ddd HH:mm:ss}")</div>
|
||||
</div>
|
||||
<div class="p-0">
|
||||
<i class="fa-solid fa-angles-right"></i>
|
||||
</div>
|
||||
<div>
|
||||
@if (@record.DataFine != null)
|
||||
{
|
||||
<div><b>@($"{@record.DataFine:yyyy/MM/dd}")</b></div>
|
||||
<div>@($"{@record.DataFine:ddd HH:mm:ss}")</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-secondary">
|
||||
<div><b>@($"{DateTime.Now:yyyy/MM/dd}")</b></div>
|
||||
<div>@($"{DateTime.Now:ddd HH:mm:ss}")</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<ODLPlot SelectedOdl="@currRecord.IdxOdl"></ODLPlot>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
<ODLPlot Id="bar1" Type="@ODLPlot.ChartType.Bar" Data="@(new[] { "10", "9" })" BackgroundColor="@(new[] { "yellow","red"})" Labels="@(new[] { "Fail","Ok"})"></ODLPlot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.SPEC.Data;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MP.SPEC.Components
|
||||
{
|
||||
@@ -123,6 +124,8 @@ namespace MP.SPEC.Components
|
||||
private List<ListValues>? ListStati;
|
||||
private List<ODLModel>? SearchRecords;
|
||||
private List<StatODLModel>? ListOdlStats;
|
||||
private List<double>? ListOdlStatsData = new List<double>();
|
||||
private List<string>? ListOdlStatsLabels = new List<string>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -178,15 +181,25 @@ namespace MP.SPEC.Components
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
private StatODLModel val2plot(int IdxStato)
|
||||
private double[] addODLData()
|
||||
{
|
||||
StatODLModel answ = new StatODLModel();
|
||||
if (ListRecords != null)
|
||||
var eleStats = ListOdlStats.Where(x => x.IdxStato == currRecord.IdxOdl).ToList();
|
||||
foreach (var item in eleStats)
|
||||
{
|
||||
answ = ListOdlStats
|
||||
.Where(x => x.IdxStato == IdxStato).SingleOrDefault();
|
||||
|
||||
ListOdlStatsData.Add(item.TotDurata);
|
||||
}
|
||||
return answ;
|
||||
return ListOdlStatsData.ToArray();
|
||||
}
|
||||
private string[] addODLLabels()
|
||||
{
|
||||
var eleStats = ListOdlStats.Where(x => x.IdxStato == currRecord.IdxOdl).ToList();
|
||||
foreach (var item in eleStats)
|
||||
{
|
||||
ListOdlStatsLabels.Add(item.Descrizione);
|
||||
}
|
||||
|
||||
return ListOdlStatsLabels.ToArray();
|
||||
}
|
||||
#endregion Private Methods
|
||||
}
|
||||
|
||||
@@ -1,63 +1,20 @@
|
||||
@*//Chart.razor*@
|
||||
@*inject IJSRuntime JSRuntime@**@
|
||||
|
||||
<canvas id="@Id"></canvas>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
private IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
|
||||
public enum ChartType
|
||||
{
|
||||
Pie,
|
||||
Bar
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public string Id { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public ChartType Type { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string[] Data { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string[] BackgroundColor { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string[] Labels { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
var config = new
|
||||
{
|
||||
Type = Type.ToString().ToLower(),
|
||||
Options = new
|
||||
@if (@SelectedOdl != -1)
|
||||
{
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<div class="px-1 border border-success rounded">
|
||||
<i class="fa-solid fa-calendar-days"></i> <b>@SelectedOdl</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<div class="px-1 flex-fill">
|
||||
@if (isLoading)
|
||||
{
|
||||
Responsive = true,
|
||||
Scales = new
|
||||
{
|
||||
YAxes = new[]
|
||||
{
|
||||
new { Ticks = new {
|
||||
BeginAtZero=true
|
||||
} }
|
||||
}
|
||||
}
|
||||
},
|
||||
Data = new
|
||||
{
|
||||
Datasets = new[]
|
||||
{
|
||||
new { Data = Data, BackgroundColor = BackgroundColor}
|
||||
},
|
||||
Labels = Labels
|
||||
<LoadingDataSmall></LoadingDataSmall>
|
||||
}
|
||||
};
|
||||
|
||||
await JSRuntime.InvokeVoidAsync("setup", Id, config);
|
||||
}
|
||||
else
|
||||
{
|
||||
<MP.SPEC.Components.Chart.Doughnut Id="@OdlId.ToString()" Type="@Chart.Doughnut.ChartType.Doughnut" Data="@Data.ToArray()" BackgroundColor="@(new[] { "yellow","red", "green"})" Labels="@Labels.ToArray()"></MP.SPEC.Components.Chart.Doughnut>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -1 +1,72 @@
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.SPEC.Components;
|
||||
using MP.SPEC.Data;
|
||||
|
||||
namespace MP.SPEC.Components
|
||||
{
|
||||
public partial class ODLPlot
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public int OdlId
|
||||
{
|
||||
get => _selParam;
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public int SelectedOdl
|
||||
{
|
||||
get => _selParam;
|
||||
set => _selParam = value;
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
//protected DataLogFilter _SelFilter { get; set; } = new DataLogFilter();
|
||||
protected int _selParam { get; set; } = -1;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
private List<StatODLModel>? ListRecords = null;
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
public List<double> Data = new List<double>();
|
||||
public List<string> Labels = new List<string>();
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
ListRecords = await MDService.StatOdl(SelectedOdl);
|
||||
foreach (var record in ListRecords)
|
||||
{
|
||||
Data.Add(record.TotDurata);
|
||||
Labels.Add($"{record.Descrizione} - {record.TotDurata:N1}min");
|
||||
}
|
||||
await Task.Delay(1);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Inject]
|
||||
protected MpDataService MDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>6.16.2210.1013</Version>
|
||||
<Version>6.16.2210.1016</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 6.16.2210.1013</h4>
|
||||
<h4>Versione: 6.16.2210.1016</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2210.1013
|
||||
6.16.2210.1016
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2210.1013</version>
|
||||
<version>6.16.2210.1016</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user