using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using System.Net.Http; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web.Virtualization; using Microsoft.JSInterop; using EgwCoreLib.BlazorTest; using EgwCoreLib.BlazorTest.Components; using EgwCoreLib.BlazorTest.Shared; using EgwCoreLib.Razor; using EgwCoreLib.Razor.Data; using static EgwCoreLib.Razor.Data.chartJsData; namespace EgwCoreLib.BlazorTest.Pages { public partial class TestMultiLine { protected override async Task OnInitializedAsync() { currDS = null; await Task.Delay(200); await setupData(); } protected List? currDS { get; set; } = null; protected List? ChLabels { get; set; } = null; protected Random rnd = new Random(); private async Task setupData() { currDS = null; List currDemo = new List(); ChLabels = new List(); int numMesi = 6; for (int iMese = 1; iMese <= numMesi; iMese++) { ChLabels.Add($"{iMese:00}"); } for (int iSerie = 0; iSerie < 4; iSerie++) { // simulo 12 mesi... List simData = new List(); for (int iMese = 1; iMese <= numMesi; iMese++) { simData.Add(new chartJsXY() { x = iMese, y = iMese + rnd.Next(-4, 4) }); } int rCol = rnd.Next(0, 155); int gCol = rnd.Next(0, 155); int bCol = rnd.Next(0, 100); chartJsData.chartJsDataSetXY singleData = new chartJsData.chartJsDataSetXY() { label = $"Data_{iSerie:00}", data = simData, borderColor = $"#{10 + rCol:X2}{30 + gCol:X2}{100 + bCol:X2}", backgroundColor = $"rgba({60 + rCol},{80 + gCol},{155 + bCol},0.3)", lineTension = 0, stepped = iSerie % 5 == 0, fill = iSerie % 3 == 0 ? "start" : "false" }; // aggiungo currDemo.Add(singleData); } currDS = currDemo; await Task.Delay(10); } protected string[] histLabel(int num) { List answ = new List(); for (int i = 0; i < 50; i++) { answ.Add($"LBL_{i:00}"); } return answ.ToArray(); } protected string[] histData(int num) { List answ = new List(); for (int i = 0; i < 50; i++) { answ.Add($"{(double)(rnd.Next(10, 100)) / 10 + i}"); } return answ.ToArray(); } } }