Time scale: skip invalid data (#8508)

This commit is contained in:
Jukka Kurkela 2021-02-23 22:31:43 +02:00 committed by GitHub
parent 99ca8334f8
commit 4207645a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 2 deletions

View File

@ -47,7 +47,7 @@ function sorter(a, b) {
*/
function parse(scale, input) {
if (isNullOrUndef(input)) {
return null;
return NaN;
}
const adapter = scale._adapter;
@ -67,7 +67,7 @@ function parse(scale, input) {
}
if (value === null) {
return value;
return NaN;
}
if (round) {

View File

@ -0,0 +1,50 @@
module.exports = {
description: 'Invalid data, https://github.com/chartjs/Chart.js/issues/5563',
config: {
type: 'line',
data: {
datasets: [{
data: [{
x: '14:45:00',
y: 20,
}, {
x: '20:30:00',
y: 10,
}, {
x: '25:15:00',
y: 15,
}, {
x: null,
y: 15,
}, {
x: undefined,
y: 15,
}, {
x: NaN,
y: 15,
}, {
x: 'monday',
y: 15,
}],
}]
},
options: {
scales: {
x: {
type: 'time',
time: {
parser: 'HH:mm:ss',
unit: 'hour'
},
},
},
layout: {
padding: 16
}
}
},
options: {
spriteText: true,
canvas: {width: 1000, height: 200}
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB