From 9b2c5e51d0b59fa799c8a6417fdfc2d29bfd7088 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 1 May 2021 11:02:42 -0400 Subject: [PATCH 1/3] Add test for DecimationAlgorithm type --- .../plugin.decimation/decimation_algorithm.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 types/tests/plugins/plugin.decimation/decimation_algorithm.ts 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 00000000000..6f2ab78e98e --- /dev/null +++ b/types/tests/plugins/plugin.decimation/decimation_algorithm.ts @@ -0,0 +1,18 @@ +import { Chart, DecimationAlgorithm } from '../../../index.esm'; + +const chart = new Chart('id', { + type: 'bubble', + data: { + labels: [], + datasets: [{ + data: [] + }] + }, + options: { + plugins: { + decimation: { + algorithm: DecimationAlgorithm.lttb, + } + } + } +}); From 4d4d8fe51f2f9b3804a2e1651a775d8428a06400 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 1 May 2021 12:10:25 -0400 Subject: [PATCH 2/3] Allow strings to be set --- types/index.esm.d.ts | 4 +- .../plugin.decimation/decimation_algorithm.ts | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index 1b9c405378e..f657ac962e4 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 index 6f2ab78e98e..978764bde90 100644 --- a/types/tests/plugins/plugin.decimation/decimation_algorithm.ts +++ b/types/tests/plugins/plugin.decimation/decimation_algorithm.ts @@ -16,3 +16,57 @@ const chart = new Chart('id', { } } }); + + +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', + } + } + } +}); From 7aebffbabb2874fc4fac25df7a4a774ae16273dc Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 1 May 2021 12:27:57 -0400 Subject: [PATCH 3/3] Linting --- types/index.esm.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index f657ac962e4..dbb34fefb22 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 | "lttb"; + algorithm: DecimationAlgorithm.lttb | 'lttb'; samples?: number; } interface MinMaxDecimationOptions extends BaseDecimationOptions { - algorithm: DecimationAlgorithm.minmax | "min-max"; + algorithm: DecimationAlgorithm.minmax | 'min-max'; } export type DecimationOptions = LttbDecimationOptions | MinMaxDecimationOptions;