Skip to content

Fix white ApexCharts backgrounds under dark themes (deepness) by setting chart.background from the theme - #54

Merged
TheWitness merged 1 commit into
mainfrom
fix/apexcharts-background
Oct 9, 2026
Merged

TheWitness merged 1 commit into
mainfrom
fix/apexcharts-background

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

PR #53 skinned the ApexCharts views from the active Cacti theme's rrdtheme.php,
but only wired up the text (foreColor), gridlines (gridColor), and the
donut track. It never set the ApexCharts chart.background, so ApexCharts kept
painting its default white plot surface regardless of the computed
theme.mode. Under any dark theme (e.g. deepness) the By Method / By Table bar
and box charts — and the import upload donut — still rendered as white boxes on a
dark page.

Details

  • slowlog_apex_theme() now also resolves the active theme's own panel
    background: the rrdtheme.php back color, falling back to the plotting
    canvas, then to white for light-theme defaults. It is normalized the same way
    as the font/grid colors and returned as a new background key.
  • That background is applied as chart.background on all three charts: the bar
    chart (renderChart), the box chart (renderBoxChart), and the upload donut
    (initDonut).
  • For deepness, this resolves to #11161d (its back), so the charts now match
    the surrounding dark panels instead of showing white.

No behavioral change to data, imports, or chart contents — colors only.

Testing

  • php -l clean on includes/functions.php, slowlog.php, and the test file.
  • tests/Unit/ApexThemeTest.php extended: back added to the dark fixture, a new
    canvas-only fixture to cover the back→canvas fallback, and background
    assertions on the light, dark, canvas-fallback, and missing-theme cases.

…emes (deepness) no longer render white chart surfaces
@TheWitness
TheWitness requested review from bmfmancini and xmacan and a balanced review from Copilot October 9, 2026 20:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation is consistent across all chart types and adequately covered by existing theme tests.

0 open findings

What changed in this PR

Adds theme-aware ApexCharts backgrounds so charts blend correctly with dark Cacti themes.

Changes:

  • Resolves chart backgrounds from back, then canvas, then white.
  • Applies the background to bar, box, and upload donut charts.
  • Extends theme tests and documents the fix.
File Description
includes/​functions.php Adds normalized background color resolution.
slowlog.php Applies the background to all ApexCharts instances.
tests/​Unit/​ApexThemeTest.php Tests theme backgrounds and fallback behavior.
CHANGELOG.md Records the dark-theme rendering fix.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@TheWitness
TheWitness merged commit 5a6cef3 into main Oct 9, 2026
6 checks passed
@TheWitness
TheWitness deleted the fix/apexcharts-background branch October 9, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants