Skip to content

Commit

Permalink
Time scale: skip invalid data (#8508)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle authored Feb 23, 2021
1 parent 99ca833 commit 4207645
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function sorter(a, b) {
*/
function parse(scale, input) {
if (isNullOrUndef(input)) {
return null;
return NaN;
}

const adapter = scale._adapter;
Expand All @@ -67,7 +67,7 @@ function parse(scale, input) {
}

if (value === null) {
return value;
return NaN;
}

if (round) {
Expand Down
50 changes: 50 additions & 0 deletions test/fixtures/scale.time/invalid-data.js
Original file line number Diff line number Diff line change
@@ -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 added test/fixtures/scale.time/invalid-data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4207645

Please sign in to comment.