feat: add percentages to tooltip
This commit is contained in:
parent
11a871fb53
commit
b9e6a86a39
|
@ -1,4 +1,4 @@
|
||||||
(function() {
|
(function () {
|
||||||
const colours = [
|
const colours = [
|
||||||
'#D32F2F',
|
'#D32F2F',
|
||||||
'#1976D2',
|
'#1976D2',
|
||||||
|
@ -17,6 +17,16 @@
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
plugins: {
|
plugins: {
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
label: function (context) {
|
||||||
|
let total = context.dataset.data.reduce((total, next) => total + next);
|
||||||
|
let percentage = (context.raw / total * 100).toFixed(2);
|
||||||
|
|
||||||
|
return `${context.label} (${percentage}%)`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
legend: {
|
legend: {
|
||||||
display: false,
|
display: false,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user