3๐
You can setting the tooltip
in the following way:
data: {
datasets: [{
label: 'My Label',
data: <?php echo json_encode($myData); ?> // contains number like: 77.43, 78.22, etc
datalabels: {
align: 'end',
anchor: 'end'
}
}],
labels: <?php echo json_encode($myLabel); ?>
},
options: {
tooltips: {
callbacks: {
label: function(tooltipItems, data) {
return data.datasets[tooltipItems.datasetIndex].label +': ' + tooltipItems.yLabel + ' %';
}
}
}
}
Reference : http://www.chartjs.org/docs/latest/configuration/tooltip.html
- Chartjs-How to make 2 bar in a certain section of chart
- Chartjs-How to sum the array value in javascript like chartjs data array and input value sum
1๐
So, I found the solution on Chartjs
Official Github Page. I just need to put
formatter: function (value) {
return value + "%";
}
inside datalabels
It acts similar with callback
in yAxes
option.
See this link
- Chartjs-VueJS : How to group by based on response data columns
- Chartjs-How can I use the data I have stored in a method after subscribe in Angular? [Angular 11]
-1๐
add quotes around php code and end with a comma: data: "<?...?>",
- Chartjs-Can't render multiple responsive canvas graphs in different tabs
- Chartjs-$scope variable do not respond to the onClick function of angular chart
Source:stackexchange.com