-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for tooltip content before draw #4034
Conversation
src/core/core.tooltip.js
Outdated
@@ -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) { | |||
// Boolean for empty tooltip | |||
var hasToolTipContent = Boolean(vm.title.length || vm.beforeBody.length || vm.body.length || vm.afterBody.length || vm.footer.length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the explicit cast to a boolean is required here. Was this from your personal code style or am I missing something subtle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not required but I thought it made the code a little bit more readable. I can remove it if it doesn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, lets leave it for now and see what @simonbrunel says. I have no real preference either way but I was leaning towards removing it just to keep the size down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @etimberg, I would remove it because it's obvious that's a boolean (a || b || c
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etimberg @simonbrunel Okay sure thing, removed the boolean casting
@etimberg Is there a recommended way to monkey patch the tooltip |
@samueljo I think you can just override |
Tooltips without any content (i.e. no
title
,beforeBody
,body
,afterBody
,footer
) should not be drawn onto canvas as empty tooltips.Add check for tooltip content in
Core.Tooltip.draw
.