]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Add test for DecimationAlgorithm type (#9010)
authorEvert Timberg <evert.timberg+github@gmail.com>
Sat, 1 May 2021 16:36:40 +0000 (12:36 -0400)
committerGitHub <noreply@github.com>
Sat, 1 May 2021 16:36:40 +0000 (12:36 -0400)
* Add test for DecimationAlgorithm type
* Allow strings to be set
* Linting

types/index.esm.d.ts
types/tests/plugins/plugin.decimation/decimation_algorithm.ts [new file with mode: 0644]

index 1b9c405378ec259e28f955a1d00607f28efcbdeb..dbb34fefb2287d81dbde9c09feeacfffa58e9e90 100644 (file)
@@ -1961,12 +1961,12 @@ interface BaseDecimationOptions {
 }
 
 interface LttbDecimationOptions extends BaseDecimationOptions {
-  algorithm: DecimationAlgorithm.lttb;
+  algorithm: DecimationAlgorithm.lttb | 'lttb';
   samples?: number;
 }
 
 interface MinMaxDecimationOptions extends BaseDecimationOptions {
-  algorithm: DecimationAlgorithm.minmax;
+  algorithm: DecimationAlgorithm.minmax | 'min-max';
 }
 
 export type DecimationOptions = LttbDecimationOptions | MinMaxDecimationOptions;
diff --git a/types/tests/plugins/plugin.decimation/decimation_algorithm.ts b/types/tests/plugins/plugin.decimation/decimation_algorithm.ts
new file mode 100644 (file)
index 0000000..978764b
--- /dev/null
@@ -0,0 +1,72 @@
+import { Chart, DecimationAlgorithm } from '../../../index.esm';
+
+const chart = new Chart('id', {
+  type: 'bubble',
+  data: {
+    labels: [],
+    datasets: [{
+      data: []
+    }]
+  },
+  options: {
+    plugins: {
+      decimation: {
+        algorithm: DecimationAlgorithm.lttb,
+      }
+    }
+  }
+});
+
+
+const chart2 = new Chart('id', {
+  type: 'bubble',
+  data: {
+    labels: [],
+    datasets: [{
+      data: []
+    }]
+  },
+  options: {
+    plugins: {
+      decimation: {
+        algorithm: 'lttb',
+      }
+    }
+  }
+});
+
+
+const chart3 = new Chart('id', {
+  type: 'bubble',
+  data: {
+    labels: [],
+    datasets: [{
+      data: []
+    }]
+  },
+  options: {
+    plugins: {
+      decimation: {
+        algorithm: DecimationAlgorithm.minmax,
+      }
+    }
+  }
+});
+
+
+const chart4 = new Chart('id', {
+  type: 'bubble',
+  data: {
+    labels: [],
+    datasets: [{
+      data: []
+    }]
+  },
+  options: {
+    plugins: {
+      decimation: {
+        algorithm: 'min-max',
+      }
+    }
+  }
+});