]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
skip non finite data points when determining scale sizes. Fixes #3125
authorEvert Timberg <evert.timberg+github@gmail.com>
Sat, 24 Sep 2016 16:19:49 +0000 (12:19 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 24 Sep 2016 16:19:49 +0000 (12:19 -0400)
src/core/core.scale.js
test/scale.linear.tests.js
test/scale.logarithmic.tests.js
test/scale.radialLinear.tests.js

index 123da31841df64e81e0c3df0d34d30d8accdbaa4..808e18e5019f32665d36c1f3d641093da9129188 100644 (file)
@@ -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
index 659ccc727cd1d28311475adac574684ce3a1f31f..3df77325848b1d7e6b82f98f887762c47357da9e 100644 (file)
@@ -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: {
index be6350341e96bfafcf02e6d59c0eebd618f5cb54..221e61c4bd2c7bb920a20dac6d205a9787410005 100644 (file)
@@ -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: {
index 61b6d96891747318ede2d6b47b192887dd723091..dea9b1b03546719b95909b352a1dfccf18e323e7 100644 (file)
@@ -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: {}