erossini / BlazorChartjs

Creates beautiful charts in Blazor using Chart.js. Library for NET6, NET7 and NET8. Source code and demo available.
https://www.puresourcecode.com/dotnet/blazor/blazor-component-for-chartjs/
MIT License
111 stars 43 forks source link

Tooltips callback doesn't work in Blazor Server #47

Open riley-cochrane opened 1 year ago

riley-cochrane commented 1 year ago

Describe the bug Does not work in .NET 6.0 Blazor Server.

To Reproduce Can reproduce by creating a fresh .NET 6 Blazor Server project, importing latest nuget version, and copying over relevant files from Demo site. I have replicated in this repo here: https://github.com/riley-cochrane/ChartJSTest Run site Go to https://localhost:7245/testgraph Hover over bar on bar graph and no tool tip displays.

Console displays error: Uncaught Error: The current dispatcher does not support synchronous calls from JS to .NET. Use invokeMethodAsync instead. at y (blazor.server.js:1:1840) at e.invokeMethod (blazor.server.js:1:2834) at config.options.plugins.tooltip.callbacks.title (Chart.js:81:27) at Tooltip.getTitle (chart.js:11425:35) at Tooltip.update (chart.js:11510:25) at Tooltip.handleEvent (chart.js:11875:14) at Object.afterEvent (chart.js:11936:25) at callback (chart.js:53:15) at PluginService._notify (chart.js:6316:11) at PluginService.notify (chart.js:6303:25)

Any fix for this? Can make local changes to create a new version if necessary.

Thanks, Riley

erossini commented 1 year ago

Hey, sorry for the late reply.

I have a similar problem with NET7 but not with NET6: the component is build on NET6. Let me check what cause this issue.