55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Plotly.Blazor;
|
|
using Plotly.Blazor.LayoutLib;
|
|
using Plotly.Blazor.Traces;
|
|
using Schaad.Accounting.Interfaces;
|
|
|
|
namespace Schaad.Accounting.UI.Components.Pages.Charts;
|
|
|
|
public partial class BookingTextOverTime : ComponentBase
|
|
{
|
|
private PlotlyChart chart = null!;
|
|
private Config? config;
|
|
private Plotly.Blazor.Layout? layout;
|
|
private IList<ITrace> data = new List<ITrace>();
|
|
|
|
[Parameter, EditorRequired]
|
|
public string AccountId { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IChartService chartService { get; set; } = null!;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
config = ChartTheme.BaseConfig();
|
|
|
|
layout = ChartTheme.BaseLayout("Nach Buchungstext im Verlauf");
|
|
layout.BarMode = BarModeEnum.Stack;
|
|
layout.BarCornerRadius = 4;
|
|
layout.HoverMode = HoverModeEnum.XUnified;
|
|
layout.XAxis = new List<XAxis>
|
|
{
|
|
new()
|
|
{
|
|
Type = Plotly.Blazor.LayoutLib.XAxisLib.TypeEnum.Category,
|
|
GridColor = ChartTheme.GridColor,
|
|
LineColor = ChartTheme.GridColor
|
|
}
|
|
};
|
|
layout.YAxis = new List<YAxis>
|
|
{
|
|
new()
|
|
{
|
|
Title = new Plotly.Blazor.LayoutLib.YAxisLib.Title { Text = "CHF" },
|
|
GridColor = ChartTheme.GridColor,
|
|
ZeroLineColor = ChartTheme.GridColor,
|
|
SeparateThousands = true
|
|
}
|
|
};
|
|
|
|
var dataSeries = await chartService.GetBookingTextExpensesPerMonthAsync(AccountId);
|
|
data = ChartTheme.BuildStackedBarTraces(ChartFormatting.FoldTail(dataSeries));
|
|
|
|
await base.OnInitializedAsync();
|
|
}
|
|
}
|