From 29743e1d63353008d53276cce6db962c636d6c39 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 9 Jun 2015 18:24:43 -0400 Subject: [PATCH] Use a polyfill when Math.log10 does not exist --- src/Chart.Core.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8034efabf..8fd4dfc0a 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -329,6 +329,13 @@ return x > 0 ? 1 : -1; } }, + log10 = helpers.log10 = function(x) { + if (Math.log10) { + return Math.log10(x) + } else { + return Math.log(x) / Math.LN10; + } + }, cap = helpers.cap = function(valueToCap, maxValue, minValue) { if (isNumber(maxValue)) { if (valueToCap > maxValue) { @@ -484,7 +491,7 @@ }, // Implementation of the nice number algorithm used in determining where axis labels will go niceNum = helpers.niceNum = function(range, round) { - var exponent = Math.floor(Math.log10(range)); + var exponent = Math.floor(helpers.log10(range)); var fraction = range / Math.pow(10, exponent); var niceFraction; -- 2.47.3