Created
February 29, 2024 07:48
-
-
Save hahwul/1ddaf42056eaea038722f08021276ca8 to your computer and use it in GitHub Desktop.
rails-charts(echarts) auto-resizing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= area_chart Rails.cache.read("data1") %> | |
<%= area_chart Rails.cache.read("data2") %> | |
<%= area_chart Rails.cache.read("data3") %> | |
<script> | |
let eChartTriggerList = document.querySelectorAll('[id^="rails_charts_"]') | |
window.addEventListener('resize', function() { | |
let eChartList = [...eChartTriggerList].map(eChartTriggerEl => echarts.init(eChartTriggerEl).resize()) | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment