From: Evert Timberg Date: Sun, 10 Apr 2016 14:10:31 +0000 (-0400) Subject: Don't measure undefined or null strings. X-Git-Tag: v2.0.1~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2234%2Fhead;p=thirdparty%2FChart.js.git Don't measure undefined or null strings. --- diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 763e88932..8eec93b24 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -830,13 +830,18 @@ module.exports = function(Chart) { ctx.font = font; var longest = 0; helpers.each(arrayOfStrings, function(string) { - var textWidth = cache.data[string]; - if (!textWidth) { - textWidth = cache.data[string] = ctx.measureText(string).width; - cache.garbageCollect.push(string); + // Undefined strings should not be measured + if (string !== undefined && string !== null) { + var textWidth = cache.data[string]; + if (!textWidth) { + textWidth = cache.data[string] = ctx.measureText(string).width; + cache.garbageCollect.push(string); + } + + if (textWidth > longest) { + longest = textWidth; + } } - if (textWidth > longest) - longest = textWidth; }); var gcLen = cache.garbageCollect.length / 2;