Fix invisible chart labels on benchmark pages#5033
Conversation
- Change Mermaid theme primaryTextColor from #ffffff to #1f2937 for readable labels - Fix CSS selectors to match actual Docusaurus Mermaid DOM structure - Add dark mode CSS overrides for chart text, background, and grid lines - Update all 7 existing benchmark markdown files and the generator script Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This PR correctly identifies and fixes the root cause of invisible chart labels — (white text) on a (white background). The fix is well-scoped and consistent across all affected files. Good work overall.
What's done well
- Root cause fix is correct: Changing from to immediately resolves the invisible-labels bug in light mode.
- CSS selector fix: is the correct Docusaurus DOM structure — the old selectors never matched anything.
- Theme-aware approach: Using and rather than hardcoded colors is exactly right for dark mode support.
- Generator script updated: Updating prevents the bug from reappearing in future auto-generated pages.
- Consistent rollout: All 7 existing markdown files updated in lock-step.
Concerns
1. CSS selectors are now global — affects ALL Mermaid diagrams, not just benchmark charts
Current:
.markdown .docusaurus-mermaid-container svg text {
fill: var(--ifm-font-color-base) !important;
}
.markdown .docusaurus-mermaid-container svg line {
stroke: var(--ifm-color-emphasis-300);
}These selectors will silently apply to every Mermaid diagram anywhere in the docs (flowcharts, sequence diagrams, ER diagrams, etc.), potentially causing unintended visual regressions if the docs ever grow beyond benchmark charts.
Suggested improvement: Use a more scoped selector, or wrap benchmark charts in a custom class:
<div className="benchmark-chart">
```mermaid
...2. The selector used for dark mode background is fragile
[data-theme='dark'] .markdown .docusaurus-mermaid-container svg .main > rect {
fill: var(--ifm-background-color) !important;
}The class is an internal Mermaid implementation detail — it's not part of any public API contract and could silently break on any Mermaid version update. The underlying cause is that the Mermaid init block hardcodes .
Suggested improvement: Rather than patching around it in CSS, consider removing the forced white background from the Mermaid config entirely:
// Remove or conditionally set this:
'background': '#ffffff',
'edgeLabelBackground': '#ffffff',Without a forced background, Mermaid should inherit the page background more naturally, eliminating the need for the fragile selector.
3. Bar color differentiation was removed without replacement
The old CSS attempted (though with broken selectors) to color-code bars by framework — TUnit green, NUnit red, MSTest amber, xUnit purple. These were removed. The bars will now fall back to Mermaid's default palette.
This is acceptable given the selectors were never working anyway, but it's worth noting as a deliberate trade-off. If per-framework colors are desired in the future, the right place is within the Mermaid config block rather than CSS (Mermaid doesn't currently support per-bar color configuration natively, so this would need to wait for Mermaid to add that feature).
Minor note
The duplicate dark mode text rule is technically redundant:
/* Light mode already sets this via --ifm-font-color-base */
[data-theme='dark'] .markdown .docusaurus-mermaid-container svg text {
fill: var(--ifm-font-color-base) !important; /* same property, same var */
}Since already adapts between light and dark, the dark-mode rule is a no-op. Not harmful, just unnecessary.
Summary
The fix solves the reported bug correctly. The main concern worth addressing before merging (or as a follow-up) is item #2 — the selector is an implementation detail of Mermaid's SVG output and could silently break on a Mermaid upgrade. The other points are lower priority, but the global CSS scope (#1) is worth keeping in mind as the docs grow.
There was a problem hiding this comment.
Code Review
This PR correctly identifies and fixes the root cause of invisible chart labels — primaryTextColor: '#ffffff' (white text) on a background: '#ffffff' (white background). The fix is well-scoped and consistent across all affected files. Good work overall.
What's done well
- Root cause fix is correct: Changing
primaryTextColorfrom#ffffffto#1f2937immediately resolves the invisible-labels bug in light mode. - CSS selector fix:
.docusaurus-mermaid-container svgis the correct Docusaurus DOM structure — the old.mermaid .xychartselectors never matched anything. - Theme-aware approach: Using
var(--ifm-font-color-base)andvar(--ifm-background-color)rather than hardcoded colors is exactly right for dark mode support. - Generator script updated: Updating
process-benchmarks.jsprevents the bug from reappearing in future auto-generated pages. - Consistent rollout: All 7 existing markdown files updated in lock-step.
Concerns
1. CSS selectors are now global — affects ALL Mermaid diagrams, not just benchmark charts
The new selectors apply to every Mermaid diagram anywhere in the docs:
.markdown .docusaurus-mermaid-container svg text { ... }
.markdown .docusaurus-mermaid-container svg line { ... }
These will silently affect flowcharts, sequence diagrams, or any other Mermaid diagram type if the docs ever grow beyond benchmark charts. This could cause unintended visual regressions.
A more scoped approach: wrap benchmark chart MDX blocks in a custom div (<div className="benchmark-chart">) and target .benchmark-chart .docusaurus-mermaid-container svg text. This isolates benchmark styling from the rest of the docs.
2. The .main > rect selector for dark mode background is fragile
[data-theme='dark'] .markdown .docusaurus-mermaid-container svg .main > rect {
fill: var(--ifm-background-color) !important;
}
The .main class is an internal Mermaid SVG implementation detail — not a public API. It could silently break on any Mermaid version update. The root cause is the hardcoded 'background': '#ffffff' in the Mermaid init block.
A better fix: remove the forced background from the Mermaid config entirely ('background': '#ffffff' and 'edgeLabelBackground': '#ffffff'). Without a forced background, Mermaid should inherit the page background naturally, eliminating the need for this fragile selector.
3. Bar color differentiation was removed without replacement
The old CSS attempted to color-code bars by framework (TUnit=green, NUnit=red, MSTest=amber, xUnit=purple). Those were removed. The old selectors were broken, so this wasn't actually working before — but it's worth noting the intent was lost. Per-bar colors in xychart-beta aren't configurable via Mermaid theme variables today, so this would require a future Mermaid update or a chart type switch to restore.
Minor note
The dark mode text rule is redundant — --ifm-font-color-base already adapts automatically between light and dark in Docusaurus, so the [data-theme='dark'] override for svg text is a no-op (same property, same CSS variable as light mode). Not harmful, just unnecessary.
Summary
The fix correctly solves the reported bug, and the screenshots confirm it works. The main concern worth addressing is #2 (fragile .main > rect selector) which could silently break on a Mermaid upgrade. The global CSS scope in #1 is a secondary maintainability concern. Neither blocks merging the immediate bug fix.
Updated [TUnit](https://github.com/thomhurst/TUnit) from 1.17.36 to 1.18.0. <details> <summary>Release notes</summary> _Sourced from [TUnit's releases](https://github.com/thomhurst/TUnit/releases)._ ## 1.18.0 <!-- Release notes generated using configuration in .github/release.yml at v1.18.0 --> ## What's Changed ### Other Changes * refactor: convert 15 manual assertions to [GenerateAssertion] by @thomhurst in thomhurst/TUnit#5029 * Fix invisible chart labels on benchmark pages by @Copilot in thomhurst/TUnit#5033 * docs: fix position of `--results-directory` in documentation by @vbreuss in thomhurst/TUnit#5038 * fix: IsEquivalentTo falls back to Equals() for types with no public members by @thomhurst in thomhurst/TUnit#5041 * perf: make test metadata creation fully synchronous by @thomhurst in thomhurst/TUnit#5045 * perf: eliminate <>c display class from generated TestSource classes by @thomhurst in thomhurst/TUnit#5047 * perf: generate per-class helper to reduce JIT compilations by ~18,000 by @thomhurst in thomhurst/TUnit#5048 * perf: consolidate per-method TestSource into per-class TestSource (~27k fewer JITs) by @thomhurst in thomhurst/TUnit#5049 * perf: eliminate per-class TestSource .ctor JITs via delegate registration by @thomhurst in thomhurst/TUnit#5051 * feat: rich HTML test reports by @thomhurst in thomhurst/TUnit#5044 ### Dependencies * chore(deps): update tunit to 1.17.54 by @thomhurst in thomhurst/TUnit#5028 * chore(deps): update dependency polyfill to 9.13.0 by @thomhurst in thomhurst/TUnit#5035 * chore(deps): update dependency polyfill to 9.13.0 by @thomhurst in thomhurst/TUnit#5036 **Full Changelog**: thomhurst/TUnit@v1.17.54...v1.18.0 ## 1.17.54 <!-- Release notes generated using configuration in .github/release.yml at v1.17.54 --> ## What's Changed ### Other Changes * docs: restructure, deduplicate, and clean up documentation by @thomhurst in thomhurst/TUnit#5019 * docs: trim, deduplicate, and restructure sidebar by @thomhurst in thomhurst/TUnit#5020 * fix: add newline to github reporter summary to fix rendering by @robertcoltheart in thomhurst/TUnit#5023 * docs: consolidate hooks, trim duplication, and restructure sidebar by @thomhurst in thomhurst/TUnit#5024 * Redesign mixed tests template by @thomhurst in thomhurst/TUnit#5026 * feat: add IsAssignableFrom<T>() and IsNotAssignableFrom<T>() assertions by @thomhurst in thomhurst/TUnit#5027 ### Dependencies * chore(deps): update tunit to 1.17.36 by @thomhurst in thomhurst/TUnit#5018 * chore(deps): update actions/upload-artifact action to v7 by @thomhurst in thomhurst/TUnit#5015 * chore(deps): update dependency microsoft.testing.extensions.codecoverage to 18.5.1 by @thomhurst in thomhurst/TUnit#5025 **Full Changelog**: thomhurst/TUnit@v1.17.36...v1.17.54 Commits viewable in [compare view](thomhurst/TUnit@v1.17.36...v1.18.0). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Mermaid xychart labels on benchmark docs pages are invisible — white text (
primaryTextColor: #ffffff) on white background. Dark mode is also broken because the CSS selectors target.mermaid .xychartwhich doesn't exist in the Docusaurus DOM (actual structure is.docusaurus-mermaid-container svg).Changes
primaryTextColorfrom#ffffffto#1f2937in all 7 benchmark markdown files and the generator script (.github/scripts/process-benchmarks.js)benchmark-charts.cssto target the actual DOM structure (.markdown .docusaurus-mermaid-container svg) instead of the non-existent.mermaid .xychartvar(--ifm-font-color-base), chart background viavar(--ifm-background-color), grid lines via emphasis colorBefore (dark mode)
After
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.