fix plot odl + modifiche grafiche

This commit is contained in:
zaccaria.majid
2022-10-14 12:39:43 +02:00
parent fba6eca9cc
commit 6c88e2687a
10 changed files with 168 additions and 142 deletions
+3 -11
View File
@@ -17,8 +17,8 @@ namespace MP.SPEC.Components.Chart
Doughnut
}
[Parameter]
public string Id { get; set; }
//[Parameter]
public string Id { get; set; } = "myChart";
[Parameter]
public ChartType Type { get; set; }
@@ -40,15 +40,7 @@ namespace MP.SPEC.Components.Chart
Options = new
{
Responsive = true,
Scales = new
{
YAxes = new[]
{
new { Ticks = new {
BeginAtZero=true
} }
}
}
},
Data = new
{
+123 -108
View File
@@ -86,119 +86,134 @@ else
<button class="btn btn-sm btn-primary py-0" type="button" @onclick="() => selectRecord(record)" data-bs-toggle="modal" data-bs-target="#staticBackdrop" title="Mostra statistiche"><i class="fa-solid fa-chart-pie"></i></button>
</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 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 col-12">
@if (currRecord != null)
{
<h3>ODL @currRecord.IdxOdl</h3>
<div class="d-flex justify-content-between">
<div class="col-8">
<div>
<table class="table">
<thead>
<tr>
<th><i class="fa-solid fa-file"></i> Articolo</th>
<th><i class="fa-solid fa-screwdriver-wrench"></i> Fase</th>
<th><i class="fa-solid fa-hard-drive"></i> Macchina</th>
<th><i class="fa-solid fa-circle-info"></i> Info ciclo</th>
<th><i class="fa-solid fa-calendar-day"></i> Periodo</th>
</tr>
</thead>
<tbody>
<tr>
<td>
@record.CodArticolo
<div class="small textConsensed text-secondary">@record.ArticoloNav.DescArticolo</div>
</td>
<td>
<div>
@tradFase(record.KeyRichiesta)
</div>
@if (record.Note != "")
{
<div class="small textConsensed text-secondary badge text-bg-light border border-secondary rounded">
<b class="text-dark"></b> <span class="text-wrap text-start"> @record.Note </span>
</div>
}
</td>
<td>
@record.IdxMacchina
<div class="small textConsensed text-secondary">@record.MachineNav.Descrizione</div>
</td>
<td>
<div class="small textConsensed"><b>N° pezzi:</b> @record.NumPezzi</div>
<div class="small textConsensed"><b>T. Ciclo:</b> @record.Tcassegnato.ToString("N3")</div>
</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>
@if (currRecord != null)
{
@if (ListOdlStats != null)
{
<ul>
@foreach (var statRecord in ListOdlStats)
{
<li>@statRecord.Descrizione - @($"{statRecord.TotDurata.ToString().Substring(0, 2)}%")</li>
}
</ul>
}
}
</div>
</div>
<div class="col-4">
<ODLPlot SelectedOdl="@currRecord.IdxOdl"></ODLPlot>
</div>
</div>
}
</div>
</div>
</div>
</div>
</td>
</tr>
}
</tbody>
</table>
<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 modal-xl">
<div class="modal-content">
<div class="modal-header">
@if (currRecord != null)
{
<h3 class="modal-title fs-5" id="staticBackdropLabel">ODL @currRecord.IdxOdl</h3>
}
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body col-12">
@if (currRecord != null)
{
<div class="d-flex justify-content-between">
<div class="col-8">
<div>
<table class="table">
<thead>
<tr>
<th><i class="fa-solid fa-file"></i> Articolo</th>
<th><i class="fa-solid fa-screwdriver-wrench"></i> Fase</th>
<th><i class="fa-solid fa-hard-drive"></i> Macchina</th>
</tr>
</thead>
<tbody>
<tr>
<td>
@currRecord.CodArticolo
<div class="small textConsensed text-secondary">@currRecord.ArticoloNav.DescArticolo</div>
</td>
<td>
<div>
@tradFase(currRecord.KeyRichiesta)
</div>
@if (currRecord.Note != "")
{
<div class="small textConsensed text-secondary badge text-bg-light border border-secondary rounded">
<b class="text-dark"></b> <span class="text-wrap text-start"> @currRecord.Note </span>
</div>
}
</td>
<td>
@currRecord.IdxMacchina
<div class="small textConsensed text-secondary">@currRecord.MachineNav.Descrizione</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="table">
<thead>
<tr>
<th><i class="fa-solid fa-circle-info"></i> Info ciclo</th>
<th class="text-center"><i class="fa-solid fa-calendar-day"></i> Periodo</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 410px">
<div class="small textConsensed"><b>N° pezzi:</b> @currRecord.NumPezzi</div>
<div class="small textConsensed"><b>T. Ciclo:</b> @currRecord.Tcassegnato.ToString("N3")</div>
</td>
<td>
<div class="small d-flex justify-content-between">
<div>
<div><b>@($"{@currRecord.DataInizio:yyyy/MM/dd}")</b></div>
<div>@($"{@currRecord.DataInizio:ddd HH:mm:ss}")</div>
</div>
<div class="p-0">
<i class="fa-solid fa-angles-right"></i>
</div>
<div>
@if (@currRecord.DataFine != null)
{
<div><b>@($"{@currRecord.DataFine:yyyy/MM/dd}")</b></div>
<div>@($"{@currRecord.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>
@if (currRecord != null)
{
@if (ListOdlStats != null)
{
@foreach (var statRecord in ListOdlStats)
{
<div class=" p-1">
<div class="text-dark badge text-bg-light rounded" style="border: 2px solid @statRecord.Css;">
<h4>@statRecord.Descrizione - @($"{calcolaPerc(statRecord.TotDurata)}%")</h4>
</div>
</div>
}
}
}
</div>
</div>
<div class="col-4">
<ODLPlot SelectedOdl="@currRecord.IdxOdl"></ODLPlot>
</div>
</div>
}
</div>
</div>
</div>
</div>
</div>
</div>
}
+22 -7
View File
@@ -182,16 +182,31 @@ namespace MP.SPEC.Components
return answ;
}
//private string calcolaPerc(double durata)
//{
// string answ = "";
private string calcolaPerc(double durata)
{
string answ = "";
// double tot = 0;
double tot = 0;
if (ListOdlStats != null)
{
// foreach
foreach (var item in ListOdlStats)
{
tot += item.TotDurata;
}
// double perc = (durata/(double)currRecord.DurataMinuti)*100;
//}
double perc = (durata / tot) * 100;
if (perc > 1)
{
answ = perc.ToString("N2");
}
else
{
answ = perc.ToString("N4");
}
}
return answ;
}
#endregion Private Methods
}
+1 -6
View File
@@ -1,10 +1,5 @@
@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)
@@ -13,7 +8,7 @@
}
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>
<MP.SPEC.Components.Chart.Doughnut Type="@Chart.Doughnut.ChartType.Doughnut" Data="@Data.ToArray()" BackgroundColor="@colors.ToArray()" Labels="@Labels.ToArray()"></MP.SPEC.Components.Chart.Doughnut>
}
</div>
</div>
+5
View File
@@ -49,14 +49,19 @@ namespace MP.SPEC.Components
public List<double> Data = new List<double>();
public List<string> Labels = new List<string>();
public List<string> colors = new List<string>();
protected async Task ReloadData()
{
Data.Clear();
Labels.Clear();
colors.Clear();
ListRecords = await MDService.StatOdl(SelectedOdl);
foreach (var record in ListRecords)
{
Data.Add(record.TotDurata);
Labels.Add($"{record.Descrizione} - {record.TotDurata:N1}min");
colors.Add(record.Css);
}
await Task.Delay(1);
isLoading = false;
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2210.1309</Version>
<Version>6.16.2210.1411</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2210.1309</h4>
<h4>Versione: 6.16.2210.1411</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2210.1309
6.16.2210.1411
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2210.1309</version>
<version>6.16.2210.1411</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>
+10 -6
View File
@@ -4,13 +4,17 @@ window.setup = (id, config) => {
//let currentDate = new Date();
//console.log(currentDate + " - Calling setup...");
console.log(id);
if (window['chart-' + id] instanceof Chart) {
if (window['myChart'] instanceof Chart) {
//window.myChart.destroy();
window['chart-' + id].destroy();
//console.log("Chart " + id + " destroyed!");
window['myChart'].destroy();
console.log("Chart " + id + " destroyed!");
window['myChart'] = new Chart(ctx, config);
}
else
{
window['myChart'] = new Chart(ctx, config);
//console.log("Chart " + id + " created!");
console.log(window['myChart']);
}
window['chart-' + id] = new Chart(ctx, config);
//console.log("Chart " + id + " created!");
console.log(window['chart-' + id]);
}