Add a total-costs-per-period line chart to the Strom page

A third chart below the existing pair, plotting ElectricityBill.TotalChf
per period.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Claudio Schaad 2026-10-26 16:29:32 +01:00
parent ec0bf7d602
commit 034bc4e0f0
2 changed files with 16 additions and 0 deletions

View file

@ -53,5 +53,11 @@
AriaLabel="Preis pro kWh für Netz, PV und Total über die Abrechnungsperioden" /> AriaLabel="Preis pro kWh für Netz, PV und Total über die Abrechnungsperioden" />
</FluentCard> </FluentCard>
</div> </div>
<FluentCard class="chart-card">
<div class="card-title">Gesamtkosten pro Periode</div>
<ChartJsChart Kind="line" Data="@costData" Height="320px"
AriaLabel="Gesamtkosten pro Abrechnungsperiode" />
</FluentCard>
} }
</div> </div>

View file

@ -31,6 +31,7 @@ public partial class Electricity : ComponentBase
private object barData = new(); private object barData = new();
private object lineData = new(); private object lineData = new();
private object costData = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -70,6 +71,15 @@ public partial class Electricity : ComponentBase
unit = "CHF/kWh", unit = "CHF/kWh",
axisDecimals = 2 axisDecimals = 2
}; };
costData = new
{
labels,
series = new object[]
{
new { name = "Total", color = ChartTheme.ColorAt(2), values = source.Select(b => (decimal?)b.TotalChf).ToList(), width = 2 }
},
unit = "CHF"
};
} }
private async Task AddAsync() private async Task AddAsync()