Files
HomeAssistant/HomeAssistant.HistoryReplay/Components/Charts/NordPoolChart.razor
T
2026-06-28 13:58:35 +03:00

33 lines
1.2 KiB
Plaintext

@code {
[Parameter] public ReplayDataSeries? DataSeries { get; set; }
private List<ReplayDataPoint> PriceData => DataSeries?.GetSeries("NordPool", "Price").ToList() ?? [];
private ApexChartOptions<ReplayDataPoint> ChartOptions => new()
{
Chart = new Chart { Background = "transparent", ForeColor = "#adb5bd" },
Theme = new Theme { Mode = Mode.Dark },
Stroke = new Stroke { Curve = Curve.Smooth, Width = 2 },
Xaxis = new XAxis { Type = XAxisType.Datetime },
Yaxis = [new YAxis { Title = new AxisTitle { Text = "ct/kWh" }, DecimalsInFloat = 2 }],
Tooltip = new Tooltip { X = new TooltipX { Format = "HH:mm" } },
Grid = new Grid { BorderColor = "#343a40" }
};
}
@if (PriceData.Count > 0)
{
<ApexChart TItem="ReplayDataPoint" Options="ChartOptions" Height="300">
<ApexPointSeries TItem="ReplayDataPoint"
Items="PriceData"
SeriesType="SeriesType.Area"
Name="Price (ct/kWh)"
XValue="p => p.Timestamp.ToLocalTime().DateTime"
YValue="p => (decimal)p.Value" />
</ApexChart>
}
else
{
<div class="text-muted text-center py-4">No price data available</div>
}