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

Allow array's in backgroundColor defaults and add hover background and border color to defaults #11931

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,12 +1611,22 @@ export interface CoreChartOptions<TType extends ChartType> extends ParsingOption
* base background color
* @see Defaults.backgroundColor
*/
backgroundColor: Scriptable<Color, ScriptableContext<TType>>;
backgroundColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
/**
* base hover background color
* @see Defaults.hoverBackgroundColor
*/
hoverBackgroundColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
/**
* base border color
* @see Defaults.borderColor
*/
borderColor: Scriptable<Color, ScriptableContext<TType>>;
borderColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
/**
* base hover border color
* @see Defaults.hoverBorderColor
*/
hoverBorderColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
/**
* base font
* @see Defaults.font
Expand Down
16 changes: 16 additions & 0 deletions test/types/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ Chart.defaults.font.size = '8';
// @ts-expect-error should be number
Chart.defaults.font.size = () => '10';

Chart.defaults.backgroundColor = 'red';
Chart.defaults.backgroundColor = ['red', 'blue'];
Chart.defaults.backgroundColor = (ctx) => ctx.datasetIndex % 2 === 0 ? 'red' : 'blue';

Chart.defaults.borderColor = 'red';
Chart.defaults.borderColor = ['red', 'blue'];
Chart.defaults.borderColor = (ctx) => ctx.datasetIndex % 2 === 0 ? 'red' : 'blue';

Chart.defaults.hoverBackgroundColor = 'red';
Chart.defaults.hoverBackgroundColor = ['red', 'blue'];
Chart.defaults.hoverBackgroundColor = (ctx) => ctx.datasetIndex % 2 === 0 ? 'red' : 'blue';

Chart.defaults.hoverBorderColor = 'red';
Chart.defaults.hoverBorderColor = ['red', 'blue'];
Chart.defaults.hoverBorderColor = (ctx) => ctx.datasetIndex % 2 === 0 ? 'red' : 'blue';

Chart.defaults.font = {
family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
size: 10
Expand Down
Loading