From: Evert Timberg Date: Tue, 9 Jun 2015 22:24:43 +0000 (-0400) Subject: Use a polyfill when Math.log10 does not exist X-Git-Tag: 2.0.0-alpha2~28^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F1186%2Fhead;p=thirdparty%2FChart.js.git Use a polyfill when Math.log10 does not exist --- 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;