Skip to content

Fix invisible chart labels on benchmark pages#5033

Merged
thomhurst merged 3 commits intomainfrom
copilot/fix-chart-label-visibility
Feb 28, 2026
Merged

Fix invisible chart labels on benchmark pages#5033
thomhurst merged 3 commits intomainfrom
copilot/fix-chart-label-visibility

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

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 .xychart which doesn't exist in the Docusaurus DOM (actual structure is .docusaurus-mermaid-container svg).

Changes

  • Mermaid theme — Changed primaryTextColor from #ffffff to #1f2937 in all 7 benchmark markdown files and the generator script (.github/scripts/process-benchmarks.js)
  • CSS selectors — Rewrote benchmark-charts.css to target the actual DOM structure (.markdown .docusaurus-mermaid-container svg) instead of the non-existent .mermaid .xychart
  • Dark mode — Added working overrides: text color via var(--ifm-font-color-base), chart background via var(--ifm-background-color), grid lines via emphasis color

Before (dark mode)

before

After

Light Dark
light dark
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: (docs) Charts labels are not visible</issue_title>
<issue_description>### Description

E.g. https://tunit.dev/docs/benchmarks/DataDrivenTests/ the background / labels of the chart are both white. (Windows darkmode using Chrome)

Image

Expected Behavior

Chart Labels should be readable.

Actual Behavior

Chart Labels are not readable.

Steps to Reproduce

  1. Windows darkmode (Android darkmode Chrome is also affected)
  2. Goto https://tunit.dev/docs/benchmarks/DataDrivenTests/
  3. Chart Labels not readable

TUnit Version

1.17.54

.NET Version

.NET 10

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

Additional Context

No response

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE</issue_description>

<agent_instructions>Let's add labels to the charts. And let's also make the charts respect dark mode themes.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 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.

Copilot AI and others added 2 commits February 28, 2026 10:19
- 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>
@thomhurst thomhurst marked this pull request as ready for review February 28, 2026 10:22
Copilot AI changed the title [WIP] Fix visibility of chart labels in dark mode Fix invisible chart labels on benchmark pages Feb 28, 2026
Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

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
...
``` Then target . This is a better architectural pattern for the future.

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.

Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

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 primaryTextColor from #ffffff to #1f2937 immediately resolves the invisible-labels bug in light mode.
  • CSS selector fix: .docusaurus-mermaid-container svg is the correct Docusaurus DOM structure — the old .mermaid .xychart selectors never matched anything.
  • Theme-aware approach: Using var(--ifm-font-color-base) and var(--ifm-background-color) rather than hardcoded colors is exactly right for dark mode support.
  • Generator script updated: Updating process-benchmarks.js 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

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.

intellitect-bot pushed a commit to IntelliTect/EssentialCSharp.Web that referenced this pull request Mar 2, 2026
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>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=TUnit&package-manager=nuget&previous-version=1.17.36&new-version=1.18.0)](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>
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.

[Bug]: (docs) Charts labels are not visible

2 participants