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

Refactor tooltip draw function to extract drawBackground method #3417

Merged
merged 1 commit into from
Oct 4, 2016
Merged
Changes from all commits
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
11 changes: 7 additions & 4 deletions src/core/core.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,12 @@ module.exports = function(Chart) {
});
}
},
drawBackground: function(pt, vm, ctx, tooltipSize, opacity) {
var bgColor = helpers.color(vm.backgroundColor);
ctx.fillStyle = bgColor.alpha(opacity * bgColor.alpha()).rgbString();
helpers.drawRoundedRectangle(ctx, pt.x, pt.y, tooltipSize.width, tooltipSize.height, vm.cornerRadius);
ctx.fill();
},
draw: function() {
var ctx = this._chart.ctx;
var vm = this._view;
Expand All @@ -689,10 +695,7 @@ module.exports = function(Chart) {

if (this._options.enabled) {
// Draw Background
var bgColor = helpers.color(vm.backgroundColor);
ctx.fillStyle = bgColor.alpha(opacity * bgColor.alpha()).rgbString();
helpers.drawRoundedRectangle(ctx, pt.x, pt.y, tooltipSize.width, tooltipSize.height, vm.cornerRadius);
ctx.fill();
this.drawBackground(pt, vm, ctx, tooltipSize, opacity);

// Draw Caret
this.drawCaret(pt, tooltipSize, opacity);
Expand Down