styd / apexcharts.rb

:bar_chart: Awesome charts for your ruby app powered by ApexCharts.JS.
https://a-styd.gitbook.io/apexcharts-ruby/
MIT License
481 stars 29 forks source link

Script generated should have possibility to have type module #79

Closed vtamara closed 2 years ago

vtamara commented 2 years ago

Is your feature request related to a problem? Please describe.

The problem is with a graph I need to update dynamically in a web application where I initialize ApexChart in a module. If I use the option defer, the graph shows first time but it doesn't update dynamically, and if I dont' use the option defer it doesn't show up the first time but it is updated correctly.

To be more concrete:

Describe the solution you'd like

That I could keep the initialization of Apexchart in a module and at the same time that I could keep using format.js to update dynamically the generation of the chart. (In future I'm planning change format.js for format.html and turbo or javascript).

Describe alternatives you've considered

I have experimented by changing apexchart.rb and found that if the non-defered script created by apexchart.rb has type='module' instead of type='text/javascript' I will have the result I expect, the graph is presented correctly initially and can be updated responding to user input by updating the script.

Analogous to the option defer, I think there should be an option module for the charts of apexchart.rb that would implement this behavior.

Additional context

vtamara commented 2 years ago

The PR #80 implements this feature

vtamara commented 2 years ago

Since #80 was merged, I'm closing this.