Files
egwcorelib/EgwCoreLib.BlazorTest/Pages/TestCompo.razor
T
Samuele Locatelli 5e71139543 Update componenti vecchi ChartJs:
- fix rispetto dimensione ext
- fix jscript
2023-06-29 17:53:57 +02:00

116 lines
3.1 KiB
Plaintext

@page "/TestCompo"
@using EgwCoreLib.Razor.Data;
@using EgwCoreLib.Utils;
<PageTitle>Test</PageTitle>
<h3>TestCompo</h3>
<div class="row">
<div class="col-6">
@if (periodo != null)
{
<div>
Periodo Selezionato: <b>@($"{periodo.Inizio:yyyy/MM/dd}") &rarr; @($"{periodo.Fine:yyyy/MM/dd}")</b>
</div>
}
</div>
<div class="col-6">
<PeriodoSel E_PeriodoSel="setPeriodo" CurrPeriodo="@periodo"></PeriodoSel>
</div>
</div>
<div class="row" style="max-height: 30rem;">
<div class="col-2">
<Doughnut Id="00" Type="@Doughnut.ChartType.Doughnut" Data="@SimData()" BackgroundColor="@colors"></Doughnut>
</div>
<div class="col-4">
<ChartHist Id="01" Data="@histData(1)" Labels="@histLabel(1)" LineColor="rgb(7, 173, 236)" BackColor="rgba(107, 223, 255, 0.5)" ChartLabel="Ore 01"></ChartHist>
</div>
<div class="col-4">
<ChartHist Id="02" Data="@histData(2)" Labels="@histLabel(2)" LineColor="rgb(173, 7, 236)" BackColor="rgba(223,107, 255, 0.5)" ChartLabel="Ore 02"></ChartHist>
</div>
<div class="col-2">
<Doughnut Id="03" Type="@Doughnut.ChartType.Doughnut" Data="@SimData()" BackgroundColor="@colors"></Doughnut>
</div>
</div>
@code {
protected DtUtils.Periodo? periodo { get; set; } = new DtUtils.Periodo(DtUtils.PeriodSet.ThisTrim);
protected async Task setPeriodo(DtUtils.Periodo newPeriodo)
{
await Task.Delay(1);
periodo = newPeriodo;
}
public List<DoughnutStyling> colors = new List<DoughnutStyling>();
public List<double> Data = new List<double>();
public List<string> Labels = new List<string>();
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
await Task.Delay(1);
}
protected double[] SimData()
{
List<double> answ = new List<double>();
double currColor = 0;
for (int i = 0; i < 10; i++)
{
currColor = (double)(rnd.Next(10, 100)) / 10;
answ.Add(currColor);
if(currColor>7)
{
colors.Add(new DoughnutStyling("#28FF69", "ccc"));
}
else if (currColor > 3)
{
colors.Add(new DoughnutStyling("orange", "ccc"));
}
else
{
colors.Add(new DoughnutStyling("red", "ccc"));
}
}
return answ.ToArray();
}
protected async Task ReloadData()
{
await Task.Delay(1);
}
protected Random rnd = new Random();
protected string[] histLabel(int num)
{
List<string> answ = new List<string>();
for (int i = 0; i < 50; i++)
{
answ.Add($"LBL_{i:00}");
}
return answ.ToArray();
}
protected string[] histData(int num)
{
List<string> answ = new List<string>();
for (int i = 0; i < 50; i++)
{
answ.Add($"{(double)(rnd.Next(10, 100)) / 10 + i}");
}
return answ.ToArray();
}
}