From: Evert Timberg Date: Sat, 24 Sep 2016 16:19:49 +0000 (-0400) Subject: skip non finite data points when determining scale sizes. Fixes #3125 X-Git-Tag: v2.4.0~1^2~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62ef40ebf6f029eb0528998b69a755874863cbbe;p=thirdparty%2FChart.js.git skip non finite data points when determining scale sizes. Fixes #3125 --- diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 123da3184..808e18e50 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -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 diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js index 659ccc727..3df773258 100644 --- a/test/scale.linear.tests.js +++ b/test/scale.linear.tests.js @@ -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: { diff --git a/test/scale.logarithmic.tests.js b/test/scale.logarithmic.tests.js index be6350341..221e61c4b 100644 --- a/test/scale.logarithmic.tests.js +++ b/test/scale.logarithmic.tests.js @@ -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: { diff --git a/test/scale.radialLinear.tests.js b/test/scale.radialLinear.tests.js index 61b6d9689..dea9b1b03 100644 --- a/test/scale.radialLinear.tests.js +++ b/test/scale.radialLinear.tests.js @@ -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: {}