mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Time scale: skip invalid data (#8508)
This commit is contained in:
parent
99ca8334f8
commit
4207645a9a
@ -47,7 +47,7 @@ function sorter(a, b) {
|
|||||||
*/
|
*/
|
||||||
function parse(scale, input) {
|
function parse(scale, input) {
|
||||||
if (isNullOrUndef(input)) {
|
if (isNullOrUndef(input)) {
|
||||||
return null;
|
return NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapter = scale._adapter;
|
const adapter = scale._adapter;
|
||||||
@ -67,7 +67,7 @@ function parse(scale, input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
return value;
|
return NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (round) {
|
if (round) {
|
||||||
|
50
test/fixtures/scale.time/invalid-data.js
vendored
Normal file
50
test/fixtures/scale.time/invalid-data.js
vendored
Normal 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}
|
||||||
|
}
|
||||||
|
};
|
BIN
test/fixtures/scale.time/invalid-data.png
vendored
Normal file
BIN
test/fixtures/scale.time/invalid-data.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue
Block a user