fix style plot

This commit is contained in:
zaccaria.majid
2022-10-18 11:10:39 +02:00
parent b4de1c9880
commit 094ce0d181
6 changed files with 56 additions and 7 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data;
using MP.SPEC.Data;
using static System.Net.Mime.MediaTypeNames;
namespace MP.SPEC.Components.Chart
@@ -28,7 +29,7 @@ namespace MP.SPEC.Components.Chart
public double[] Data { get; set; }
[Parameter]
public string[] BackgroundColor { get; set; }
public List<DoughnutStyling> BackgroundColor { get; set; }
[Parameter]
public string[] Labels { get; set; }
@@ -46,7 +47,7 @@ namespace MP.SPEC.Components.Chart
{
Datasets = new[]
{
new { Data = Data, BackgroundColor = BackgroundColor
new { Data = Data, BackgroundColor = BackgroundColor.Select(x=>x.color), borderColor = BackgroundColor.Select(x=>x.border), borderWidth= 0, offset= 10, borderRadius = 10
}
},
Labels = Labels
+1 -1
View File
@@ -224,7 +224,7 @@ else
</div>
<div class="progress">
<div class="progress-bar @colorChanger(@stat.Css)" role="progressbar" aria-valuenow="0" aria-valuemin="0" style="width: @Math.Round(calcolaPerc(stat.TotDurata),0)%; background-color:@stat.Css;" aria-valuemax="100">@($"{calcolaPerc(stat.TotDurata):N1}%")</div>
<div class="progress-bar @colorChanger(@stat.Css)" role="progressbar" aria-valuenow="0" aria-valuemin="0" style="width: @Math.Round(calcolaPerc(stat.TotDurata),0)%; background-color:@pbStyle(@stat.Css);" aria-valuemax="100">@($"{calcolaPerc(stat.TotDurata):N1}%")</div>
</div>
</div>
+20 -1
View File
@@ -277,7 +277,26 @@ namespace MP.SPEC.Components
}
return answ;
}
private string pbStyle(string css)
{
string answ = "";
if (ListOdlStats != null)
{
if (css == "yellow")
{
answ ="orange";
}
else if (css == "blue")
{
answ = "purple";
}
else
{
answ = css;
}
}
return answ;
}
private async void MessageService_EA_PageUpdated()
{
await reloadData();
+1 -1
View File
@@ -7,7 +7,7 @@
}
else
{
<MP.SPEC.Components.Chart.Doughnut Type="@Chart.Doughnut.ChartType.Doughnut" Data="@Data.ToArray()" BackgroundColor="@colors.ToArray()"></MP.SPEC.Components.Chart.Doughnut>
<MP.SPEC.Components.Chart.Doughnut Type="@Chart.Doughnut.ChartType.Doughnut" Data="@Data.ToArray()" BackgroundColor="@colors"></MP.SPEC.Components.Chart.Doughnut>
}
</div>
}
+15 -2
View File
@@ -49,7 +49,7 @@ 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>();
public List<DoughnutStyling> colors = new List<DoughnutStyling>();
protected async Task ReloadData()
{
@@ -61,7 +61,20 @@ namespace MP.SPEC.Components
{
Data.Add(record.TotDurata);
Labels.Add($"{record.Descrizione} - {record.TotDurata:N1}min");
colors.Add($"{record.Css}");
if (record.Css == "yellow")
{
colors.Add(new DoughnutStyling("orange", "ccc"));
}
else if (record.Css == "blue")
{
colors.Add(new DoughnutStyling("purple", "ccc"));
}
else
{
colors.Add(new DoughnutStyling(record.Css, "ccc"));
}
}
await Task.Delay(1);
isLoading = false;
+16
View File
@@ -0,0 +1,16 @@
using System.Drawing;
namespace MP.SPEC.Data
{
public class DoughnutStyling
{
public string color { get; set; }
public string border { get; set; }
public DoughnutStyling(string color, string border)
{
this.color = color;
this.border = border;
}
}
}