]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Allow array for line opts in dataset (#10179)
authorJacco van den Berg <39033624+LeeLenaleee@users.noreply.github.com>
Mon, 21 Feb 2022 02:31:42 +0000 (03:31 +0100)
committerGitHub <noreply@github.com>
Mon, 21 Feb 2022 02:31:42 +0000 (21:31 -0500)
* fix line as array ts error

* added test

* implement only for the border,background color and radius

types/index.esm.d.ts
types/tests/controllers/line_styling_array.ts [new file with mode: 0644]

index a4f463c25b14d41ce3c589db68cae440041549c3..ace3a249f7ca5bcf6082f001f7f83f5452ba0baf 100644 (file)
@@ -177,8 +177,10 @@ export interface LineControllerDatasetOptions
   extends ControllerDatasetOptions,
   ScriptableAndArrayOptions<PointPrefixedOptions, ScriptableContext<'line'>>,
   ScriptableAndArrayOptions<PointPrefixedHoverOptions, ScriptableContext<'line'>>,
-  ScriptableOptions<LineOptions, ScriptableContext<'line'>>,
-  ScriptableOptions<LineHoverOptions, ScriptableContext<'line'>>,
+  ScriptableOptions<Omit<LineOptions, keyof CommonElementOptions>, ScriptableContext<'line'>>,
+  ScriptableAndArrayOptions<CommonElementOptions, ScriptableContext<'line'>>,
+  ScriptableOptions<Omit<LineHoverOptions, keyof CommonHoverOptions>, ScriptableContext<'line'>>,
+  ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'line'>>,
   AnimationOptions<'line'> {
   /**
    * The ID of the x axis to plot this dataset on.
diff --git a/types/tests/controllers/line_styling_array.ts b/types/tests/controllers/line_styling_array.ts
new file mode 100644 (file)
index 0000000..3b6c673
--- /dev/null
@@ -0,0 +1,13 @@
+import { Chart } from '../../index.esm';
+
+const chart = new Chart('id', {
+  type: 'line',
+  data: {
+    labels: [],
+    datasets: [{
+      data: [],
+      backgroundColor: ['red', 'blue'],
+      hoverBackgroundColor: ['red', 'blue'],
+    }]
+  },
+});