apexcharts / Blazor-ApexCharts

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

Cleaner solution for binding isDark? (ThemeMode) #456

Open StephenOTT opened 2 months ago

StephenOTT commented 2 months ago

Is there a solution to bind the theme mode without having to add handling for manually re-rendering each chart, etc?

Would be nice if there was just a @bind-IsDark="@isDark" that could be setup instead of having to setting up themes, callbacks, etc.

joadan commented 2 months ago

Hi,

It's a tradeoff what options to expose with razor syntax, currently we have no plans o expose theme with razor syntax. One technique to make thing easier is to have a service or a singleton class to provide default chart options.

StephenOTT commented 2 months ago

The complexity with the singleton approach is dealing with multiple charts per page.

You end up having to re-write all of the infra to understand when and how to call the theme change per chart in a single page for an overall app setting.

Even if it was not specific a theme change exposure, but some "something changed that needs chart action" that takes a Func so we can change settings generically across multiple instances of charts.

Currently it feels like you have to create factory-factories of chart settings, keep track of all of the refs and then call each to re-render.