From ea7b8cb04f528fe0c9fac526f2bdbf809397d0bd Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 1 May 2021 12:36:40 -0400 Subject: [PATCH] Add test for DecimationAlgorithm type (#9010) * Add test for DecimationAlgorithm type * Allow strings to be set * Linting --- types/index.esm.d.ts | 4 +- .../plugin.decimation/decimation_algorithm.ts | 72 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 types/tests/plugins/plugin.decimation/decimation_algorithm.ts 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', + } + } + } +}); -- 2.47.2