1👍
✅
You will have to use a custom tooltip callback like this:
options: {
plugins: {
tooltip: {
callbacks: {
label: (ttItem) => (`${ttItem.label}: Rp. ${ttItem.parsed}`)
}
}
}
}
Documentation: https://www.chartjs.org/docs/latest/configuration/tooltip.html#tooltip-callbacks
V2:
options: {
tooltips: {
callbacks: {
label: (ttItem, items) => (`${items.labels[ttItem.index]}: R. ${items.datasets[ttItem.datasetIndex].data[ttItem.index]}`)
}
}
}
Example V3:
var options = {
type: 'pie',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
}]
},
options: {
plugins: {
tooltip: {
callbacks: {
label: (ttItem) => (`${ttItem.label}: Rp. ${ttItem.parsed}`)
}
}
}
}
}
var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.2.0/chart.js"></script>
</body>
Example V2:
var options = {
type: 'pie',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
}]
},
options: {
tooltips: {
callbacks: {
label: (ttItem, items) => (`${items.labels[ttItem.index]}: R. ${items.datasets[ttItem.datasetIndex].data[ttItem.index]}`)
}
}
}
}
var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.js"></script>
</body>
Source:stackexchange.com