From 68b493732c29b544eac0d72526d1981407c8d26f Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 10 Apr 2016 10:10:31 -0400 Subject: [PATCH] Don't measure undefined or null strings. --- src/core/core.helpers.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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; -- 2.47.2