From: Evert Timberg Date: Sat, 1 May 2021 16:36:40 +0000 (-0400) Subject: Add test for DecimationAlgorithm type (#9010) X-Git-Tag: v3.2.1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea7b8cb04f528fe0c9fac526f2bdbf809397d0bd;p=thirdparty%2FChart.js.git Add test for DecimationAlgorithm type (#9010) * Add test for DecimationAlgorithm type * Allow strings to be set * Linting --- diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index 1b9c40537..dbb34fefb 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -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 index 000000000..978764bde --- /dev/null +++ b/types/tests/plugins/plugin.decimation/decimation_algorithm.ts @@ -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', + } + } + } +});