Skip to content
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

Merged
merged 2 commits into from
Mar 21, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/core.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Member

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).

Copy link
Contributor Author

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


if (this._options.enabled && hasToolTipContent) {
// Draw Background
this.drawBackground(pt, vm, ctx, tooltipSize, opacity);

Expand Down