]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove scriptability from defaults.font types (#9794)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Fri, 29 Oct 2021 11:32:12 +0000 (14:32 +0300)
committerGitHub <noreply@github.com>
Fri, 29 Oct 2021 11:32:12 +0000 (07:32 -0400)
* Remove scriptability from defaults.font types

* Remove failing test

types/index.esm.d.ts
types/tests/defaults.ts
types/tests/scriptable_core_chart_options.ts

index 6e36c9ab4bdc37389448f3c7fb96129570057786..550842f32970c8054f363f2547d47ab1a0a8ccf8 100644 (file)
@@ -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
index d6dba5ad6dd55a5058fbffd0310fc609fbde2193..850eb059acc63faa94e0e9d1e46e1f2962b0402c 100644 (file)
@@ -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
+};
index 8039f3c0dbb426b627b4cae80bf6a70f26be9beb..2c81f592e6cc286c56c4c38a4aaf44fd9a123a24 100644 (file)
@@ -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' }
     }
   };
 };