Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backgroundColor doesn't always support string array #11912

Closed
teodorachiosa opened this issue Oct 1, 2024 · 0 comments · Fixed by #11931
Closed

backgroundColor doesn't always support string array #11912

teodorachiosa opened this issue Oct 1, 2024 · 0 comments · Fixed by #11931
Labels
type: types Typescript type changes

Comments

@teodorachiosa
Copy link

Expected behavior

backgroundColor should support string and string[] in:
Chart.defaults.backgroundColor

Current behavior

Using TypeScript, I'm getting this error when using an array of colors for backgroundColor:

Chart.defaults.backgroundColor = ['red', 'blue'];
TS2322: Type 'string[]' is not assignable to type 'Scriptable<Color, ScriptableContext>'.

All Chart.js examples use arrays of colors, this should be supported.

A similar thing has been logged here as an improvement: #10123, but I think it's a bug.

Reproducible sample

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUG2pjFQCYCmedAFcANjDpUARujIBrAOaEhAOx7III6HAC8cANokAxHjwAGc6ZIAaUofMnzJALot2rAG6Y4ZGAA8dcDwQZEIgfMrc8nwwAKIifGERAEIAngCSPAAUAEQgKZyw2QCUcOh0cAASACoAsgAyyOjKnnRxCeEwrp5QcHkF8LrKfADuKJQwmT6+NghscPNwMClgfABcpGDAfNZzCzzoMOjrs6wLZ3Ai6JJ8InTretkASnw82TbZSSJCfG9w2QCaN00w1+2QA4lA+OFQQAFIRQMDxUEAeSgTSi2ScVl250CBzK0Tu+hOuNxl2uInWRjgEDwcAAahAYHwGNjTqSzvtDvcAIwAJhsPIAnDYAMw2ACsNgFcFFWJx52wTgV2DZZwgYBgwAgyiJJPOdDI6HieoVZ18xzN5yt81VNrgKUt7I59uwVrdzpwbGwRVcbCAA

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.4.4

Browser name and version

Chrome: 129.0.6668.70 (Official Build) (64-bit)

Link to your project

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: types Typescript type changes
Projects
None yet
2 participants