mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Refactor tooltip draw function to extract drawBackground method
See issue #3416.
This commit is contained in:
parent
365bdbb346
commit
b64cab0046
@ -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;
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user