]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Update tooltip colour draw code
authorEvert Timberg <evert.timberg@gmail.com>
Fri, 13 Nov 2015 13:20:39 +0000 (08:20 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Fri, 13 Nov 2015 13:20:39 +0000 (08:20 -0500)
src/core/core.tooltip.js

index 9b87df38836cb06f9ff21e9c0ca55fad2b6fde4f..2ce84a91dbb093217a52993ebf72922b4092a40c 100644 (file)
 
                                        // Draw Legend-like boxes if needed
                                        if (this._options.tooltips.mode != 'single') {
-                                               ctx.fillStyle = helpers.color(vm.labelColors[i].borderColor).alpha(vm.opacity).rgbString();
+                                               // Fill a white rect so that colours merge nicely if the opacity is < 1
+                                               ctx.fillStyle = helpers.color('#FFFFFF').alpha(vm.opacity).rgbaString();
                                                ctx.fillRect(xBase, yBase, vm.bodyFontSize, vm.bodyFontSize);
 
-                                               ctx.fillStyle = helpers.color(vm.labelColors[i].backgroundColor).alpha(vm.opacity).rgbString();
+                                               // Border
+                                               ctx.strokeStyle = helpers.color(vm.labelColors[i].borderColor).alpha(vm.opacity).rgbaString();
+                                               ctx.strokeRect(xBase, yBase, vm.bodyFontSize, vm.bodyFontSize);
+
+                                               // Inner square
+                                               ctx.fillStyle = helpers.color(vm.labelColors[i].backgroundColor).alpha(vm.opacity).rgbaString();
                                                ctx.fillRect(xBase + 1, yBase + 1, vm.bodyFontSize - 2, vm.bodyFontSize - 2);
 
-                                               ctx.fillStyle = helpers.color(vm.bodyColor).alpha(vm.opacity).rgbString(); // Return fill style for text
+                                               ctx.fillStyle = helpers.color(vm.bodyColor).alpha(vm.opacity).rgbaString(); // Return fill style for text
                                        }
 
                                        // Body Line