Closed mars888 closed 2 months ago
After a bit of tracing, it seems that the issue is that the Options
attribute on ApexChart
is set multiple times by Blazor (each time with a new ApexChartOptions<_>
instance).
This can sometimes happen after PrepareChart
has been called (I assume this happens when the interface updates/renders and the order here is dependent on how the user interacts with the page or maybe just timing). As the options are cleanly created in this case, the Series
property will be null
as SetSeries
will not have been called. This in turn causes the line var series = ChartReference.Options.Series.ElementAt(selectedDataPoints.SeriesIndex)
in JsHandler.JSDataPointEnter
/JsHandler.JSDataPointSelected
to explode with a System.ArgumentNullException
.
Is creating new options for the Options
attribute something that is expected and supported in such a case?
Hi In your code you get a new ApexchartsOptions object each time the Options Parameter is read. You should use an variable and new it up once.
Please check the samples like https://apexcharts.github.io/Blazor-ApexCharts/features/axis
Ok, we have some complex logic where some of the graph parameters and incoming data could change, and we combine these updates in a functional (immutable) way. But I understand why this is something that would not be supported and we can certainly find ways to work around this. Thank you for your response!
Hi there!
We have recently run into a strange behavior after upgrading a Blazor WebAssembly application to .NET 8. We have a page with a number of bar graphs displaying a limited amount of data. The first load of this page is fine and the graph displays without issues. The first click on a data entry works without issues as well, but any subsequent clicks produce the following error in the browser console:
I've reduced the code in question to this minimal reproducible sample that still produces this error:
Of note here is that the errors go away when either the
Options
or theOnDataPointSelection
attributes are removed. I've spent about a day and a half on this, but I can't seem to figure out where this is coming from.This is using Blazor-ApexCharts version 3.3.0. Any ideas or insights on this behavior are greatly appreciated!