From: Mickael Jeanroy Date: Tue, 4 Oct 2016 15:08:55 +0000 (+0200) Subject: Refactor tooltip draw function to extract drawBackground method X-Git-Tag: v2.4.0~1^2~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b64cab004669a010025e4641eb7f359c4035f6b9;p=thirdparty%2FChart.js.git Refactor tooltip draw function to extract drawBackground method See issue #3416. --- diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 1c9a1fdb1..54f9f49f5 100755 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -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);