Skip to content

Commit

Permalink
skip non finite data points when determining scale sizes. Fixes #3125
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Sep 24, 2016
1 parent ba13387 commit 62ef40e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/scale.linear.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions test/scale.logarithmic.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ 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]
}, {
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: {
Expand Down
4 changes: 2 additions & 2 deletions test/scale.radialLinear.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down

0 comments on commit 62ef40e

Please sign in to comment.