I was doing some research and I was wondering if it is possible to make a custom tooltip like in chart.js, I couldn't find anything. I would like to add some css to my tooltip! I am using angular5.
Asked
Active
Viewed 3,491 times
3
-
here is the documentation https://www.chartjs.org/docs/latest/configuration/tooltip.html#external-custom-tooltips – Kenry Sanchez Mar 15 '19 at 20:55
1 Answers
3
Try to add this in your chart options:
public barChartOptions: ChartOptions = {
...
tooltips: {
backgroundColor: 'rgba(255,255,0,0.5)',
bodyFontColor: 'blue',
borderColor: '#0ff',
borderWidth: 5,
caretPadding: 10,
displayColors: false,
enabled: true,
intersect: true,
mode: 'x',
titleFontColor: '#333',
titleMarginBottom: 10,
xPadding: 20,
yPadding: 15,
// If you want to custom the value
callbacks: {
label: function (tooltipItem, data) {
const datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
return datasetLabel + ': $' + tooltipItem.yLabel;
}
}
},
}
See also this answer: https://stackoverflow.com/a/54890570

Avi
- 117
- 1
- 6