Fixed label callbacks adding only a single line instead of multiple lines as stated in docs.

This commit is contained in:
Robert Becker 2016-02-04 10:34:29 +01:00
parent f4bcef13f5
commit e7df265c7a
2 changed files with 14 additions and 5 deletions

View File

@ -844,4 +844,15 @@
isDatasetVisible = helpers.isDatasetVisible = function(dataset) {
return !dataset.hidden;
};
isDatasetVisible = helpers.pushAllIfDefined = function(element, array) {
if (typeof element == "undefined") {
return;
}
if (isArray(element)) {
array.push.apply(array, element);
} else {
array.push(element);
}
};
}).call(this);

View File

@ -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;