]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Show color box only on the first line of the tooltip body (#6984)
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 19 Jan 2020 14:03:51 +0000 (09:03 -0500)
committerGitHub <noreply@github.com>
Sun, 19 Jan 2020 14:03:51 +0000 (09:03 -0500)
* Show color box only on the first line of the tooltip body
* Code review feedback

src/core/core.tooltip.js

index e00b486e78fe1cfe51a18af5d0c892fe9853b59b..5aff16c63e06e05d858a7a3bbf5f60228cd443d5 100644 (file)
@@ -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]);
                        }