Skip to content

Commit becfb39

Browse files
committed
Improve chart color initialization in Firefox iframes
- Use requestAnimationFrame to ensure charts complete initial render - Read CSS variables from documentElement with body fallback - Fixes issue where charts showed default colors until manual toggle
1 parent 41988f4 commit becfb39

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Source/HTML/script.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,7 +3605,10 @@ var plot_radar = {
36053605
};
36063606

36073607
function cssvar(name) {
3608-
return getComputedStyle(document.body).getPropertyValue(name);
3608+
// Read from documentElement (html) instead of body for better iframe compatibility
3609+
const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
3610+
// Fallback to body if empty
3611+
return value || getComputedStyle(document.body).getPropertyValue(name).trim();
36093612
}
36103613

36113614
function updateChartColors(c, colorVariables) {
@@ -8180,9 +8183,14 @@ if (isAndroid()) showMenu();
81808183

81818184
main();
81828185

8183-
// Ensure chart colors are applied after all stylesheets are loaded (fixes Firefox iframe issue)
8186+
// Ensure chart colors are applied after all stylesheets are loaded and charts are fully rendered (fixes Firefox iframe issue)
81848187
window.addEventListener('load', () => {
8185-
updateAllChartColors();
8188+
// Use requestAnimationFrame to ensure charts have completed their initial render
8189+
requestAnimationFrame(() => {
8190+
requestAnimationFrame(() => {
8191+
updateAllChartColors();
8192+
});
8193+
});
81868194
});
81878195

81888196
//checkLatestVersion();

0 commit comments

Comments
 (0)