From: Tanner Linsley Date: Mon, 22 Jun 2015 19:10:49 +0000 (-0600) Subject: Support for custom tooltips again X-Git-Tag: 2.0.0-alpha4~70 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=25fd84490b722aa4046b412251bcb16ec6496611;p=thirdparty%2FChart.js.git Support for custom tooltips again --- diff --git a/samples/line-customTooltips.html b/samples/line-customTooltips.html index a9ee1b85c..a480f8092 100644 --- a/samples/line-customTooltips.html +++ b/samples/line-customTooltips.html @@ -5,22 +5,22 @@ Line Chart with Custom Tooltips - @@ -40,48 +41,80 @@
-
- -
- -
- - diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 94df818a6..0ec578290 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -446,7 +446,7 @@ // Built in Tooltips - if (this.options.tooltips.enabled) { + if (this.options.tooltips.enabled || this.options.tooltips.custom) { // The usual updates this.tooltip.initialize(); diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 1423f7ae5..90539681a 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -207,10 +207,6 @@ var ctx = this._chart.ctx; var vm = this._view; - if (this._options.tooltips.custom) { - this._options.tooltips.custom(this); - } - switch (this._options.hover.mode) { case 'single': @@ -242,6 +238,12 @@ ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); // Custom Tooltips + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + if (!this._options.tooltips.enabled) { + return; + } switch (vm.yAlign) { case "above": @@ -285,6 +287,14 @@ break; case 'label': + // Custom Tooltips + if (this._options.tooltips.custom) { + this._options.tooltips.custom(this); + } + if (!this._options.tooltips.enabled) { + return; + } + helpers.drawRoundedRectangle(ctx, vm.x, vm.y - vm.height / 2, vm.width, vm.height, vm.cornerRadius); ctx.fillStyle = helpers.color(vm.backgroundColor).alpha(vm.opacity).rgbString(); ctx.fill();