]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Do not draw tooltips that have no items (#4034)
authorSamuel Jo <samueljo@users.noreply.github.com>
Tue, 21 Mar 2017 00:40:28 +0000 (20:40 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Tue, 21 Mar 2017 00:40:28 +0000 (20:40 -0400)
src/core/core.tooltip.js

index 16fcb099b36d72c23d8023df6f0656c2b5153a69..15574a8274a85ce69cc9745c5f5bf022008ec71b 100755 (executable)
@@ -789,7 +789,10 @@ module.exports = function(Chart) {
                        // IE11/Edge does not like very small opacities, so snap to 0
                        var opacity = Math.abs(vm.opacity < 1e-3) ? 0 : vm.opacity;
 
-                       if (this._options.enabled) {
+                       // Truthy/falsey value for empty tooltip
+                       var hasTooltipContent = vm.title.length || vm.beforeBody.length || vm.body.length || vm.afterBody.length || vm.footer.length;
+
+                       if (this._options.enabled && hasTooltipContent) {
                                // Draw Background
                                this.drawBackground(pt, vm, ctx, tooltipSize, opacity);