-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Labels
Description
As tooltips are triggered on Elements, a hierarchical callback definition could be made - callbacks are called if defined in (in order of preference):
- the dataset
- the axis
- the chart
- the chart globals
The reasoning behind this feature is that while creating a complex chart with different needs for label formatting, I found myself doing this a lot:
chartOptions = {
[...]
tooltips: {
callbacks: {
label: function (tooltip, data) {
// real implementation accounts for nonexistent object properties
var datasetCallback = data.datasets[tooltip.datasetIndex].tooltips.callbacks.label;
if (typeof datasetCallback === 'function') {
return datasetCallback(tooltip, data);
}
return tooltip.yLabel;
}
}
}
}