avatar
Hespethorn
HespethornのBlog
GitHub
Recent Posts
Website Info
Article Count :
505
Runtime :
Total Word Count :
844.1k
Last Update :
document.getElementById(chartID).getContext('2d') const config = JSON.parse(chartDefinition) const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark-mode' : 'light-mode' // Set default styles (initial setup) applyThemeDefaultsConfig(theme) // Automatically traverse the config and apply dual-mode color schemes applyThemeConfig(config, theme) new Chart(ctx, config) }) } const loadChartJS = () => { const chartJSEle = document.querySelectorAll('#article-container .chartjs-container') if (chartJSEle.length === 0) return window.loadChartJS ? runChartJS(chartJSEle) : btf.getScript('https://cdn.jsdelivr.net/npm/chart.js/dist/chart.umd.min.js').then(() => runChartJS(chartJSEle)) } // Listen for theme change events btf.addGlobalFn('themeChange', loadChartJS, 'chartjs') btf.addGlobalFn('encrypt', loadChartJS, 'chartjs') window.pjax ? loadChartJS() : document.addEventListener('DOMContentLoaded', loadChartJS) })()