mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-19 06:36:51 +01:00
skip non finite data points when determining scale sizes. Fixes #3125
This commit is contained in:
@@ -398,8 +398,8 @@ module.exports = function(Chart) {
|
||||
if (rawValue === null || typeof(rawValue) === 'undefined') {
|
||||
return NaN;
|
||||
}
|
||||
// isNaN(object) returns true, so make sure NaN is checking for a number
|
||||
if (typeof(rawValue) === 'number' && isNaN(rawValue)) {
|
||||
// isNaN(object) returns true, so make sure NaN is checking for a number; Discard Infinite values
|
||||
if (typeof(rawValue) === 'number' && !isFinite(rawValue)) {
|
||||
return NaN;
|
||||
}
|
||||
// If it is in fact an object, dive in one more level
|
||||
|
||||
@@ -156,9 +156,9 @@ describe('Linear Scale', function() {
|
||||
data: {
|
||||
datasets: [{
|
||||
yAxisID: 'yScale0',
|
||||
data: [null, 90, NaN, undefined, 45, 30]
|
||||
data: [null, 90, NaN, undefined, 45, 30, Infinity, -Infinity]
|
||||
}],
|
||||
labels: ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
labels: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
|
||||
@@ -224,7 +224,7 @@ describe('Logarithmic Scale tests', function() {
|
||||
data: [undefined, 10, null, 5, 5000, NaN, 78, 450]
|
||||
}, {
|
||||
yAxisID: 'yScale0',
|
||||
data: [undefined, 28, null, 1000, 500, NaN, 50, 42]
|
||||
data: [undefined, 28, null, 1000, 500, NaN, 50, 42, Infinity, -Infinity]
|
||||
}, {
|
||||
yAxisID: 'yScale1',
|
||||
data: [undefined, 30, null, 9400, 0, NaN, 54, 836]
|
||||
@@ -232,7 +232,7 @@ describe('Logarithmic Scale tests', function() {
|
||||
yAxisID: 'yScale1',
|
||||
data: [undefined, 0, null, 800, 9, NaN, 894, 21]
|
||||
}],
|
||||
labels: ['a', 'b', 'c', 'd', 'e', 'f' ,'g']
|
||||
labels: ['a', 'b', 'c', 'd', 'e', 'f' ,'g', 'h', 'i']
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
|
||||
@@ -132,9 +132,9 @@ describe('Test the radial linear scale', function() {
|
||||
type: 'radar',
|
||||
data: {
|
||||
datasets: [{
|
||||
data: [50, 60, NaN, 70, null, undefined]
|
||||
data: [50, 60, NaN, 70, null, undefined, Infinity, -Infinity]
|
||||
}],
|
||||
labels: ['lablel1', 'label2', 'label3', 'label4', 'label5', 'label6']
|
||||
labels: ['lablel1', 'label2', 'label3', 'label4', 'label5', 'label6', 'label7', 'label8']
|
||||
},
|
||||
options: {
|
||||
scales: {}
|
||||
|
||||
Reference in New Issue
Block a user