Skip to content

Conversation

@jonathan-fulton
Copy link

Summary

Fixes #12079

When color strings contain CSS-style comments (e.g., rgba(255, 0, 0 /* red */, 0.5)), the color interpolation during animation would fail because the color helper couldn't parse the commented string.

Changes

  • Added stripCssComments helper function to remove /* ... */ style comments from color strings
  • Applied the stripping before passing colors to the color interpolation functions

Use Case

Some users document their colors inline using CSS comments, which is valid CSS but wasn't being handled by Chart.js's animation system:

backgroundColor: 'rgba(255, 0, 0 /* red */, 0.5)'

This fix ensures such colors can still be animated properly.

…ation

When color values contain CSS comments like 'rgba(255,0,0, /*alpha*/ 0.5)',
the color interpolator would fail to parse them correctly, causing
color transitions to not animate smoothly.

This fix strips CSS /* ... */ comments from color strings before passing
them to the color parser, allowing transitions to work even with
commented color values.

Fixes chartjs#12079
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.

Color transitions do not work when CSS comments are in the color strings

1 participant