Repository navigation
[Bug Fix] Chart: fix theme colors and default to --chart-1..5 - #582
Merged
Merged
Conversation
getThemeColor split each token on spaces and wrapped it in hsl(), which dates from when the tokens were HSL triples. The theme now uses oklch(...), so it produced strings like hsl(oklch(20.5%, 0, 0)). The canvas rejects them and Chart.js drew everything in black, which made bar and line charts nearly invisible in dark mode. Pass the token value through as-is. The legend borderRadius also read --radius through getThemeColor; use a fixed 2px instead, matching the rounded-[2px] legend indicator in shadcn's chart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Datasets defaulted to a background fill with a primary border, so every series looked the same. Color dataset i with --chart-(i % 5 + 1), as shadcn's chart examples do; pie, doughnut and polar area charts color each slice instead. Colors set on a dataset still win. Docs: explain the default and add a multiple datasets example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Chart.js accepts keyed object data ({ a: 10, b: 20 }); calling .map on
it threw while building the default slice colors. Use Object.values so
array and object data both get one color per value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picks up the updated chart controller and the new "Multiple datasets" docs example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Turn on auto-fix | Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Chart controller was drawing every chart in black.
getThemeColorsplit each CSS token on spaces and wrapped it inhsl(), which worked when the tokens were HSL triples. The theme now usesoklch(...), so the controller produced strings likehsl(oklch(20.5%, 0, 0)). The canvas rejects those, and Chart.js fell back to black for bars, grid lines, ticks and tooltips. In dark mode the bar and line charts were close to invisible. Found while working on #581.Changes
getThemeColorreturns the token value unchanged. The canvas acceptsoklch()in current Chrome, Safari (16.4+) and Firefox (113+).borderRadiuswas also read throughgetThemeColor('radius')and came out ashsl(.625rem, undefined, undefined). It is now a fixed 2px, matching therounded-[2px]legend indicator in shadcn's Base UI chart.--chart-1through--chart-5in order, as in shadcn's chart examples. Pie, doughnut and polar area charts color each slice instead. Before this, every dataset got a--backgroundfill with a--primaryborder, so all series looked alike. Colors set on a dataset still take precedence, as the pie example on the docs page shows.docs/app/views/docs/chart.rbandgem/lib/ruby_ui/chart/chart_docs.rb.With the neutral
--chart-Nvalues from #581, the default series come out in grays, as in shadcn's neutral theme.Screenshots
| Dark |
|
|
Testing
cd docs && bin/dev, open/docs/chart.cd gem && bundle exec rake;cd docs && bin/rails db:test:prepare test && bundle exec standardrb.🤖 Generated with Claude Code
Summary by cubic
Fixes charts rendering entirely in black and making every series look alike. The chart controller wrapped the theme's
oklch()tokens inhsl(), which the canvas rejects, and gave every dataset the same background fill with a primary border.borderRadiusis a fixed 2px instead of reading--radiusthrough the same path.--chart-1to--chart-5in order, while pie, doughnut, and polar area charts color each slice instead. Explicit dataset colors still take precedence.Written for commit ced33e4. Summary will update on new commits.