-
Notifications
You must be signed in to change notification settings - Fork 12k
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:
ChartOptions<'doughnut'>
// throws a Type error at backgroundColor
{
backgroundColor: ((ctx) => {
return ['blue', 'grey']
})
}Looking at the source code, I found that now it says:
backgroundColor: Scriptable<Color, ScriptableContext<TType>>;
// only accepts string or a fn that returns a stringit will allow a string array if I change it to
backgroundColor: ScriptableAndArray<Color, ScriptableContext<TType>>;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