I had a similar problem in one of my projects where I was updating a bar chart.
What I did was make a variable exampleChart
referencing the ApexChart
component and then call exampleChart.UpdateSeriesAsync()
method to update the chart whenever and wherever I want.
With your code, it would be like so:
@code :
private ApexChart<ChartData>? exampleChart { get; set; }
private async Task ReloadChartSeries()
{
if (exampleChart is not null)
await exampleChart.UpdateSeriesAsync();
}
view :
<ApexChart @ref="exampleChart" TItem="spGetGraphPloegen" Options="chartOptionsVroege" Height="300">
<ApexPointSeries TItem="spGetGraphPloegen"
Items="GraphVroege"
Name="Vroege"
SeriesType="SeriesType.Line"
XValue="e => e.Ts"
YValue="e => (decimal)e.Cap_Act" />
</ApexChart>
After that, you just have to call ReloadChartSeries()
when you are selecting the new day.
Someone posted a similar question with the javascript tag:
https://stackoverflow.com/questions/74314021/how-do-i-refresh-new-data-in-apexcharts