Skip to content

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

Open
@gian-didom

Description

@gian-didom

Expected behavior

when transitioning from this:

chart.data.dataset[0].backgroundColor = 'rgba(255,0,0, /*alpha*/ 0.5)

to this:

chart.data.dataset[0].backgroundColor = 'rgba(0,255,0, /*alpha*/ 0.5)

I would expect the transition to happen regardless of the comment in the /* */.

Current behavior

Despite the final colors being correctly applied, there is no transition between the color in any setting. Color transition happens instantly

Reproducible sample

https://codepen.io/Gianfry7/pen/qEddoZg

Optional extra steps/info to reproduce

Refer to the codepen for a sample.

Possible solution

I think the problem is in the default color interpolator which is not able to remove the commen, while the interpreter for the canvas does. One may regex away all the /* */ content when parsing the color.

Context

I incurred in this bug while trying to lazily apply border and background colors with a single settings for datasets.

chart.js version

latest

Browser name and version

No response

Link to your project

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions