Add test for DecimationAlgorithm type (#9010)

* Add test for DecimationAlgorithm type
* Allow strings to be set
* Linting
This commit is contained in:
Evert Timberg 2021-05-01 12:36:40 -04:00 committed by GitHub
parent 55dd426a41
commit ea7b8cb04f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 2 deletions

View 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;

View File

@ -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',
}
}
}
});