mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 12:49:07 +02:00
Fixed label callbacks adding only a single line instead of multiple lines as stated in docs.
This commit is contained in:
parent
f4bcef13f5
commit
ba6afa7257
@ -844,4 +844,15 @@
|
|||||||
isDatasetVisible = helpers.isDatasetVisible = function(dataset) {
|
isDatasetVisible = helpers.isDatasetVisible = function(dataset) {
|
||||||
return !dataset.hidden;
|
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);
|
}).call(this);
|
||||||
|
@ -162,11 +162,9 @@
|
|||||||
var lines = [];
|
var lines = [];
|
||||||
|
|
||||||
helpers.each(tooltipItems, function(bodyItem) {
|
helpers.each(tooltipItems, function(bodyItem) {
|
||||||
var beforeLabel = this._options.tooltips.callbacks.beforeLabel.call(this, bodyItem, data) || '';
|
helpers.pushAllIfDefined(this._options.tooltips.callbacks.beforeLabel.call(this, bodyItem, data), lines);
|
||||||
var bodyLabel = this._options.tooltips.callbacks.label.call(this, bodyItem, data) || '';
|
helpers.pushAllIfDefined(this._options.tooltips.callbacks.label.call(this, bodyItem, data), lines);
|
||||||
var afterLabel = this._options.tooltips.callbacks.afterLabel.call(this, bodyItem, data) || '';
|
helpers.pushAllIfDefined(this._options.tooltips.callbacks.afterLabel.call(this, bodyItem, data), lines);
|
||||||
|
|
||||||
lines.push(beforeLabel + bodyLabel + afterLabel);
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
|
Loading…
Reference in New Issue
Block a user