diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index 6e36c9ab4bd..550842f3297 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -1417,7 +1417,7 @@ export interface CoreChartOptions extends ParsingOption * base font * @see Defaults.font */ - font: Scriptable, ScriptableContext>; + font: Partial; /** * Resizes the chart canvas when its container does (important note...). * @default true diff --git a/types/tests/defaults.ts b/types/tests/defaults.ts index d6dba5ad6dd..850eb059acc 100644 --- a/types/tests/defaults.ts +++ b/types/tests/defaults.ts @@ -7,3 +7,16 @@ Chart.defaults.plugins.title.display = false; Chart.defaults.datasets.bar.backgroundColor = 'red'; Chart.defaults.animation = { duration: 500 }; + +Chart.defaults.font.size = 8; + +// @ts-expect-error should be number +Chart.defaults.font.size = '8'; + +// @ts-expect-error should be number +Chart.defaults.font.size = () => '10'; + +Chart.defaults.font = { + family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + size: 10 +}; diff --git a/types/tests/scriptable_core_chart_options.ts b/types/tests/scriptable_core_chart_options.ts index 8039f3c0dbb..2c81f592e6c 100644 --- a/types/tests/scriptable_core_chart_options.ts +++ b/types/tests/scriptable_core_chart_options.ts @@ -8,7 +8,6 @@ const getConfig = (): ChartConfiguration<'bar'> => { }, options: { backgroundColor: (context) => context.active ? '#fff' : undefined, - font: (context) => context.datasetIndex === 1 ? { size: 10 } : { size: 12, family: 'arial' } } }; };