apexcharts / Blazor-ApexCharts

A blazor wrapper for ApexCharts.js

Home Page:https://apexcharts.github.io/Blazor-ApexCharts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support .NET formatters on Blazor Server

danielchalmers opened this issue · comments

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

Alternative is to use JavaScript.

Discussion continued from #37 (comment)

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

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.

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.