backgroundColor to allow type string[] and scriptable string[]
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Feature Proposal
I've been attempting to get variable backgroundcolors for a doughnut charts based on their value. Each would have a variable color, followed by a base color (grey). The idea I had was to have a few if statements to check the value and then render the correct array of colors, but the current typing does not allow for an array. It would be a great fix to allow you to use arrays as the background color with ts support.
There's a type mistake in the source code where it doesn't allow something that's possible with just JS. It renders correctly if I cast to `any` but TS doesn't allow it:
```ts
ChartOptions<'doughnut'>
// throws a Type error at backgroundColor
{
backgroundColor: ((ctx) => {
return ['blue', 'grey']
})
}
```
Looking at the source code, I found that now it says:
```ts
backgroundColor: Scriptable>;
// only accepts string or a fn that returns a string
```
it will allow a string array if I change it to
```ts
backgroundColor: ScriptableAndArray>;
```
but what I need is to allow a function that returns a string array. Wasn't sure how to do that!
### Possible Implementation
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.