apexcharts / Blazor-ApexCharts

A blazor wrapper for ApexCharts.js
https://apexcharts.github.io/Blazor-ApexCharts
MIT License
749 stars 88 forks source link

Support .NET formatters on Blazor Server #433

Open danielchalmers opened 4 months ago

danielchalmers commented 4 months ago

Currently the .NET formatting option is only available on WASM. image

Alternative is to use JavaScript.

Discussion continued from https://github.com/apexcharts/Blazor-ApexCharts/issues/37#issuecomment-1996807246

The problem here is that we can’t make an async request from the sync javascript method.

danielchalmers commented 4 months ago

Related: #400

joadan commented 3 months ago

The challenge here is that the formatter functions in apexcharts.js is syncronous. In blazor server we need to make an async request, as far as I know there is no clean way to do this.

Hackish solutions like polling etc is not something we will implement.

SparkyTD commented 2 months ago

If the only goal is to avoid hard-coded JS formatter expression or to provide type-safety with the rest of the .NET codebase, then one (possibly rather unhinged) solution would be making use of System.Linq.Expressions.Expression to "transpile" an actual C# expression into a JS function. This could cover simple use cases like adding a prefix/postfix to the formatted value. But obviously it wouldn't be able to do anything more complex that would rely on actual server-side C# logic.