using Microsoft.AspNetCore.Components; using Plotly.Blazor; using Plotly.Blazor.Traces; using Schaad.Accounting.Interfaces; namespace Schaad.Accounting.UI.Components.Pages.Charts; public partial class Assets : ComponentBase { private PlotlyChart chart = null!; private Config? config; private Plotly.Blazor.Layout? layout; private IList? data; [Inject] private IViewService viewService { get; set; } = null!; protected override async Task OnInitializedAsync() { config = new Config { Responsive = true }; layout = new Plotly.Blazor.Layout { }; var accounts = (await viewService.GetAccountViewListAsync()).Where(a => a.Class == ClassIds.Activa); var values = new List(); var labels = new List(); var ids = new List(); foreach (var account in accounts) { if (account.BalanceCHF > 0) { values.Add(account.BalanceCHF); labels.Add(account.Name); ids.Add(account.Id); } } data = new List { new Pie { Values = values, Labels = labels, Ids = ids } }; await base.OnInitializedAsync(); } }