From: Evert Timberg Date: Sun, 19 Jan 2020 14:03:51 +0000 (-0500) Subject: Show color box only on the first line of the tooltip body (#6984) X-Git-Tag: v3.0.0-alpha~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=216ac702613391d3dc0e8d864ada8a938295a866;p=thirdparty%2FChart.js.git Show color box only on the first line of the tooltip body (#6984) * Show color box only on the first line of the tooltip body * Code review feedback --- diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index e00b486e7..5aff16c63 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -788,12 +788,12 @@ class Tooltip extends Element { helpers.each(bodyItem.before, fillLineOfText); lines = bodyItem.lines; - for (j = 0, jlen = lines.length; j < jlen; ++j) { - // Draw Legend-like boxes if needed - if (displayColors) { - me._drawColorBox(ctx, pt, i, rtlHelper); - } + // Draw Legend-like boxes if needed + if (displayColors && lines.length) { + me._drawColorBox(ctx, pt, i, rtlHelper); + } + for (j = 0, jlen = lines.length; j < jlen; ++j) { fillLineOfText(lines[j]); }