Skip to content

Resolve chart colours from theme tokens - #19

Merged
LukasWallrich merged 2 commits into
mainfrom
fix/theme-aware-charts
Oct 9, 2026
Merged

LukasWallrich merged 2 commits into
mainfrom
fix/theme-aware-charts

Conversation

@LukasWallrich

@LukasWallrich LukasWallrich commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Charts hard-coded about 60 light-theme colours and kept three copies of the same Plotly theme function. In dark mode this meant:

  • plots sat on a different background (#1d1e29) from their cards (#241d23);
  • the citation "Replication published" line and label used the light maroon #8b1a4a (1.84:1 on dark cards);
  • failed-red #b3331e was 2.67:1, below the 3:1 minimum for chart marks;
  • study-timeline labels sat on white boxes.

Changes

  • New --color-chart-* series tokens in ds-tokens.css. Light outcome-series colours are unchanged; dark values keep every mark at ≥ 3:1 against --color-surface-raised. The exception is not-coded, which stays deliberately faint (2.6:1) because it represents unassessed rows. Axis, grid and legend colours, and the "all originals" citation line, now come from the FORRT tokens, so they shift slightly in light mode (e.g. grid #dfd8e5 → #e0e1e1, citation line #8b1a4a → brand #853953).
  • FloraCharts.token() / FloraCharts.theme() read tokens at render time. OUTCOME_COLORS and REPRODUCTION_COLORS become getters. mcPlotlyTheme, aoPlotlyTheme and plotlyTheme collapse into one.
  • Plotly charts default to the page font (Source Sans 3) instead of the unloaded Inter or Plotly's default.
  • An open citation-timeline dialog re-renders when the theme is toggled.

Outcome categories, labels and data are unchanged. This brings back item 1 of the salvage review of the closed #7.

Verification

  • python -m unittest: 15 tests OK.
  • npm test (Playwright Chromium): 12/12.
  • Script check in both themes: every Chart.js and Plotly chart on Overview, Mean Citedness, Authorship Overlap and Citation Impact uses the themed surface, grid and series colours, with no page errors. The only 404 is data/fect_results.json, which also happens on main.

Review follow-up (5d308ed)

The theme-toggle redraw now only re-renders the study that is currently shown and rendered. This addresses cubic's stale-redraw finding; the race was not reachable from the UI, because the dialog makes the toggle inert. The dark-token comment now names the not-coded exception.

🤖 Generated with Claude Code


Summary by cubic

Makes charts resolve colours from CSS tokens at render time, so plots follow the active theme instead of a hard-coded light palette. In dark mode plots previously sat on a background different from their cards, some marks fell below the 3:1 contrast minimum, and study-timeline labels sat on white boxes.

  • New --color-chart-* tokens keep the light palette unchanged; dark values keep every mark at ≥ 3:1 against the raised surface, except --color-chart-not-coded, which stays deliberately faint.
  • The three duplicate Plotly theme functions collapse into FloraCharts.theme(), and outcome colour maps read tokens via FloraCharts.token().
  • Plots default to the page font instead of the unloaded Inter, and the open study timeline redraws on theme toggle when it is still the current study and its plot exists.

Written for commit 5d308ed. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Improvements
    • Charts now use shared theme colors, backgrounds, and typography, including when switching between light and dark themes.
    • The currently displayed Citation Impact timeline updates to match the selected theme.
    • Added chart colors for successful, failed, mixed, inconclusive, qualified, and other outcome types, as well as technical-failure, not-checked, not-coded, and neutral results.

Charts hard-coded about 60 light-theme colours and kept three copies of
the same Plotly theme function, so in dark mode plots sat on a
different background from their cards, the citation reference line was
the light maroon (1.84:1 on dark cards), failed-red was 2.67:1 and the
study-timeline labels sat on white boxes.

- Add --color-chart-* series tokens with dark values that keep every
  mark at >= 3:1 against the raised surface; light values are unchanged.
- FloraCharts.token()/theme() read tokens at render time; outcome colour
  maps become getters, and the three Plotly theme functions collapse
  into one.
- Plotly charts default to the page font instead of the unloaded Inter.
- An open study timeline re-renders on theme toggle.

Brought back from the closed #7 redesign.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 612ccf6e-6bfd-4628-9a60-48d91c16acdb

📥 Commits

Reviewing files that changed from the base of the PR and between 1ed227e and 8051489.


📒 Files selected for processing (4)
  • assets/app.js
  • assets/chart-accessibility.js
  • assets/citation-impact.js
  • assets/ds-tokens.css

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

Charts now read colors, surfaces, and typography from shared theme values and CSS tokens. The Citation Impact timeline also redraws when the theme changes while its study modal is open.

Changes

Chart theme integration

Layer / File(s) Summary
Shared chart tokens and theme API
assets/ds-tokens.css, assets/chart-accessibility.js
Light and dark themes define chart-series color tokens. FloraCharts resolves chart theme values, exposes token and theme, and applies the page font to Plotly layouts unless the layout already specifies font properties.
Main chart theme integration
assets/app.js
Outcome palettes, axes, and chart styling use shared theme values. Mean Citedness, Authorship Overlap, Registered Reports, Publication Status, and large-scale project charts no longer use their removed local theme functions.
Citation Impact charts and theme updates
assets/citation-impact.js
Citation Impact plots use shared theme values for outcome colors, lines, markers, annotations, backgrounds, and typography. The open study is retained so its timeline can be redrawn after a theme change when its modal is visible.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: lukasroeseler


Merge Risk: ⚪ Minimal · up to 80514

Chart colors meet the stated dark-theme contrast target, with the documented not-coded exception, and rendered charts update when the theme changes. No identified issue blocks merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue #7 is closed and supplies historical context only. It does not impose active coding requirements for this pull request. The PR objectives describe chart token resolution, theme-aware chart rende…
Out of Scope Changes check Passed The reported changes stay within the stated chart theming scope. They add chart tokens, resolve chart colors and Plotly theme values at render time, consolidate duplicate theme logic, apply the page f…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: resolving chart colours from theme tokens.

Full details: Docstring Coverage

Explanation

Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 3 files. (1 skipped: 1 unsupported.)



  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="assets/app.js">

<violation number="1" location="assets/app.js:55">
P3: This changes the light-theme axis and legend palette despite the PR promise that light-theme chart colors remain unchanged. Preserve the existing light values, or add chart-axis tokens with those exact values.</violation>
</file>

<file name="assets/citation-impact.js">

<violation number="1" location="assets/citation-impact.js:19">
P3: This token does not preserve the existing light-theme color: `--color-primary` is `#853953`, but the `all` series previously rendered as `#8b1a4a`. Use a dedicated token whose light value retains `#8b1a4a` and whose dark value provides the intended contrast.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread assets/app.js
Comment on lines +55 to +56
const t = FloraCharts.theme();
return { grid: t.grid, tick: t.tick, legend: t.font };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This changes the light-theme axis and legend palette despite the PR promise that light-theme chart colors remain unchanged. Preserve the existing light values, or add chart-axis tokens with those exact values.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At assets/app.js, line 55:

<comment>This changes the light-theme axis and legend palette despite the PR promise that light-theme chart colors remain unchanged. Preserve the existing light values, or add chart-axis tokens with those exact values.</comment>

<file context>
@@ -50,12 +52,8 @@ function disciplineForJournal(journalName) {
-        tick:   dark ? '#b8b5c4' : '#4e4858',
-        legend: dark ? '#e8e6ee' : '#2a2330'
-    };
+    const t = FloraCharts.theme();
+    return { grid: t.grid, tick: t.tick, legend: t.font };
 }
</file context>
Suggested change
const t = FloraCharts.theme();
return { grid: t.grid, tick: t.tick, legend: t.font };
const dark = currentTheme() === 'dark';
return {
grid: dark ? '#2d2e3d' : '#dfd8e5',
tick: dark ? '#b8b5c4' : '#4e4858',
legend: dark ? '#e8e6ee' : '#2a2330'
};

Comment thread assets/citation-impact.js
get failed() { return FloraCharts.token('--color-chart-failed'); },
get successful() { return FloraCharts.token('--color-chart-successful'); },
get mixed() { return FloraCharts.token('--color-chart-mixed'); },
get all() { return FloraCharts.token('--color-primary'); },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This token does not preserve the existing light-theme color: --color-primary is #853953, but the all series previously rendered as #8b1a4a. Use a dedicated token whose light value retains #8b1a4a and whose dark value provides the intended contrast.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At assets/citation-impact.js, line 19:

<comment>This token does not preserve the existing light-theme color: `--color-primary` is `#853953`, but the `all` series previously rendered as `#8b1a4a`. Use a dedicated token whose light value retains `#8b1a4a` and whose dark value provides the intended contrast.</comment>

<file context>
@@ -11,8 +11,12 @@
+        get failed()     { return FloraCharts.token('--color-chart-failed'); },
+        get successful() { return FloraCharts.token('--color-chart-successful'); },
+        get mixed()      { return FloraCharts.token('--color-chart-mixed'); },
+        get all()        { return FloraCharts.token('--color-primary'); },
     };
 
</file context>

Comment thread assets/citation-impact.js Outdated
Comment thread assets/ds-tokens.css Outdated
- Clear the remembered study when a new one starts loading and redraw only
  if the shown study is still current and its plot exists (cubic review).
- The dark chart-token comment now names --color-chart-not-coded as the
  deliberate exception to the 3:1 rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukasWallrich
LukasWallrich merged commit 32cb154 into main Oct 9, 2026
2 of 3 checks passed
LukasWallrich added a commit that referenced this pull request Oct 9, 2026
Resolve conflicts with #19 and #20: renderMcCharts keeps
FloraCharts.theme() (which also drops the stale #8b1a4a fallback), and
the outlined-button rules keep this branch's --color-* tokens with #20's
per-button transition timings.

Also restore a visible stats-card hover border (--color-primary-border);
it had become a no-op after the token rename (cubic review).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

1 participant