19👍
You can add units to tooltips using tooltip callbacks configuration.
For example, here is how to add “GB” unit to the tooltip:
const options = {
tooltips: {
callbacks: {
label: (item) => `${item.yLabel} GB`,
},
},
}
- [Chartjs]-Chart.js – how to disable everything on hover
- [Chartjs]-Chartjs 2 – Stacked bar and unstacked line on same chart with same y axis
8👍
I found that the options API has changed in later versions of Chart.js (v3.7.0 as of writing).
An example of adding temperature units is as follows:
const options = {
plugins: {
tooltip: {
callbacks: {
label: (item) =>
`${item.dataset.label}: ${item.formattedValue} °C`,
},
},
},
}
3👍
for Angular 7, This works for me, might help you:
options: {
tooltips: {
callbacks: {
label: (tooltipItems, data) => {
return data.datasets[tooltipItems.datasetIndex].data[tooltipItems.index] + ' GB';
}
},
}
Source:stackexchange.com