mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Provide different default tooltip functions for horizontal bar
This commit is contained in:
parent
f44350ad14
commit
d0dd7ceabe
@ -346,6 +346,28 @@ module.exports = function(Chart) {
|
||||
rectangle: {
|
||||
borderSkipped: 'left'
|
||||
}
|
||||
},
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
title: function(tooltipItems, data) {
|
||||
// Pick first xLabel for now
|
||||
var title = '';
|
||||
|
||||
if (tooltipItems.length > 0) {
|
||||
if (tooltipItems[0].yLabel) {
|
||||
title = tooltipItems[0].yLabel;
|
||||
} else if (data.labels.length > 0 && tooltipItems[0].index < data.labels.length) {
|
||||
title = data.labels[tooltipItems[0].index];
|
||||
}
|
||||
}
|
||||
|
||||
return title;
|
||||
},
|
||||
label: function(tooltipItem, data) {
|
||||
var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
|
||||
return datasetLabel + ': ' + tooltipItem.xLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user