Closed MartijnWoudstra closed 4 years ago
The error is really strange cause there is no parameter in Blazorise named jsRuntime
. All I can think of is that your chart data are not initialized properly. Please look at #590 issue, it might be the same problem as yours.
@stsrki
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeAsync[TValue](IJSRuntime jsRuntime, String identifier, Object[] args)
My guess is the injection of the IJSRuntime (parameter called jsRuntime) is going wrong somehow. The issue linked by you does not fix the issue
That was my first thought also. But there is no reason for it to not be injected. It's Blazor thing. All I have is this code: [Inject] IJSRuntime JSRuntime { get; set; }
, and that should be enough to be injected by the framework.
Can you create and push a sample project so I can have a look?
I found your problem.
First: Add <script src="_content/Blazorise.Charts/blazorise.charts.js"></script>
to the _Host.cshtml
.
Second: You have radarChart = new RadarChart<double>();
in your HandleRedraw()
function. That is the problem because that is the reference for Blazor component. You should never initialize variables that you use for @ref
attribute.
I removed it and now it works.
async Task HandleRedraw()
{
radarChart.Clear();
radarChart.AddLabel( new string[] { "", "", "", "", "", "", "", "", } );
//RadarChart.AddLabel(new string[] { "Axis 1","Axis 2", "Axis 4",
// "Axis 5", "Axis 7","Axis 8", "Axis 10", "Axis 11" });
radarChart.AddDataSet( await GetRadarChartDataset() );
try
{
await radarChart.Update();
}
catch ( Exception e )
{
Console.WriteLine( e.StackTrace );
}
}
PS. I also changed GetRadarChartDataset().Result
to await GetRadarChartDataset()
. Otherwise Result could lead to deadlocks.
Thanks, works!
Describe the bug System.ArgumentNullException: Value cannot be null. (Parameter 'jsRuntime')
To Reproduce Steps to reproduce the behavior:
Expected behavior A graph nicely drawn
Additional context
Error log:
Code: MyChart.razor
Startup: