mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-20 23:26:53 +01:00
Remove scriptability from defaults.font types (#9794)
* Remove scriptability from defaults.font types * Remove failing test
This commit is contained in:
2
types/index.esm.d.ts
vendored
2
types/index.esm.d.ts
vendored
@@ -1417,7 +1417,7 @@ export interface CoreChartOptions<TType extends ChartType> extends ParsingOption
|
||||
* base font
|
||||
* @see Defaults.font
|
||||
*/
|
||||
font: Scriptable<Partial<FontSpec>, ScriptableContext<TType>>;
|
||||
font: Partial<FontSpec>;
|
||||
/**
|
||||
* Resizes the chart canvas when its container does (important note...).
|
||||
* @default true
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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' }
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user