Repository navigation
feat(frontend): theme charts and the correlation heatmap for dark mode - #532
Conversation
Automated review summaryTriage: enhancement | Recommendation: ready-for-maintainer Findings
Conventions
This PR replaces the hardcoded light palette in ChartRenderer and CorrelationHeatmap with the existing --app-* theme tokens. I confirmed that every token and Tailwind alias it uses (--app-grid, --app-elevated, --app-disabled-foreground, bg-surface-hover, ring-foreground and the rest) is defined in index.css for both light and dark. The PNG export correctly resolves the token values at click time, since a standalone SVG cannot read var(). I found no correctness or security problems, only minor test-robustness nits (the leaked-style cleanup and the reliance on Recharts internal class names). The PR follows Conventional Commits, has a single commit, and its description links the issue it closes (#210). It is fine to merge once the repo's CI checks pass. Generated by |
ChartRenderer and CorrelationHeatmap were written before dark mode landed and hardcode a light palette, so on a dark background they render as bright panels: grey grid and axis lines, a white tooltip and hover cursor, white-midpoint heatmap cells and a white diagonal in the PNG export. Point the chart chrome at the theme tokens from index.css instead. Grid, axis, ticks, tooltip, cursor and pie slice borders reference the --app-* custom properties, so the .dark block restyles them and the navbar toggle repaints an open chart without a rerender. The heatmap mixes its diverging red/blue scale toward the surface token with color-mix(), so 0 sits on the panel colour in both themes and strong cells keep white text. Null cells, the diagonal, dividers, the hover ring and the highlight values use the existing theme classes. The SVG export cannot resolve var(), so it reads the token values off the document element at click time and bakes them in. Adds a ChartRenderer test that mounts a chart under a dark ThemeProvider and extends the heatmap tests to cover the mixed fills, the highlight classes and the exported palette. Fixes c2siorg#210
7b733c4 to
3778581
Compare
|
@ivantha the Slack invite on the GSoC page has expired. Can you share a new one? Thanks. |
Description
ChartRendererandCorrelationHeatmaplanded before dark mode and hardcode a light palette, so on a dark background they render as bright panels: grey grid and axis lines, a white tooltip and hover cursor, white-midpoint heatmap cells and a white diagonal in the PNG export.This points the chart chrome at the theme tokens from
index.cssinstead of a second palette in the chart files:ChartRenderer.tsx: grid, axis line, tick and label text, tooltip box (background, border, text) and the tooltip cursor reference the--app-*custom properties; pie slices are separated with--app-surfaceinstead of#fff. The.darkblock restyles them, so the navbar toggle repaints an open chart without a rerender.CorrelationHeatmap.tsx:cellColormixes the red/blue hue toward--app-surfacewithcolor-mix(), so the diverging scale is centred on the panel colour in both themes;textColorkeeps white on strong fills and uses--app-foregroundotherwise. Null cells, the diagonal, the highlights dividers and the hover ring use the existing theme classes, and the highlight values usetext-blue-600 dark:text-blue-400/text-red-600 dark:text-red-400. The legend gradient passes through--app-surface.var(), soexportPalettereads the token values off the document element at click time andbuildMatrixSvgbakes them in. The exported PNG matches the theme it was downloaded from.Series colours and the pie ramp are data colours and are unchanged.
Fixes #210
Type of Change
How Has This Been Tested?
ChartRenderer.test.tsx(new): mounts a bar chart under a darkThemeProviderand asserts the grid, axis, ticks and tooltip reference the theme tokens; asserts pie slices use the surface token; toggles the theme throughuseThemeand asserts the chart keeps the same token references while thedarkclass flips.CorrelationHeatmap.test.tsx: three new cases for thecolor-mix()cell fills and text colours, the null cell and legend classes, the highlight value classes, and the exported SVG carrying the resolved dark token values.Manual: ran the app locally, rendered bar (with tooltip), area, scatter, pie and the heatmap (matrix, highlights, PNG export) in light and dark mode before and after; screenshots attached.
Existing tests pass
New tests added
Manual testing
Screenshots (if applicable)
Taken from the app running locally,
mainvs this branch.Light mode, after:
Checklist