diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 08fc3a419..470bc0d9c 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -844,4 +844,15 @@ isDatasetVisible = helpers.isDatasetVisible = function(dataset) { return !dataset.hidden; }; + pushAllIfDefined = helpers.pushAllIfDefined = function(element, array) { + if (typeof element == "undefined") { + return; + } + + if (isArray(element)) { + array.push.apply(array, element); + } else { + array.push(element); + } + }; }).call(this); diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 2ce84a91d..8ae52854e 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -162,11 +162,9 @@ var lines = []; helpers.each(tooltipItems, function(bodyItem) { - var beforeLabel = this._options.tooltips.callbacks.beforeLabel.call(this, bodyItem, data) || ''; - var bodyLabel = this._options.tooltips.callbacks.label.call(this, bodyItem, data) || ''; - var afterLabel = this._options.tooltips.callbacks.afterLabel.call(this, bodyItem, data) || ''; - - lines.push(beforeLabel + bodyLabel + afterLabel); + helpers.pushAllIfDefined(this._options.tooltips.callbacks.beforeLabel.call(this, bodyItem, data), lines); + helpers.pushAllIfDefined(this._options.tooltips.callbacks.label.call(this, bodyItem, data), lines); + helpers.pushAllIfDefined(this._options.tooltips.callbacks.afterLabel.call(this, bodyItem, data), lines); }, this); return lines;