我正在使用 Chart.js 插件来显示条形图,我得到的输出如下:
My question is about, how to add a custom text after rendering a value to bar? For example, In Jan, value is showing 56. I want to add % increased/decreased information next to it (i.e. 56 [115 %]) How to do this?
这是我的代码
window.chartHeadcount = new Chart(document.getElementById("barChartHeadcount"), {
type: 'bar',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [{
label: 'Billed',
backgroundColor: 'rgb(0, 197, 106)',
data: billedHeadCount
}, {
label: 'Unbilled',
backgroundColor: 'rgb(255, 114, 107)',
data: unBilledHeadCount
}]
},
options: {
title: {
display: true,
text: 'Community Headcount - ' + Options.Globals.Year
},
tooltips: {
mode: 'index',
intersect: false
},
responsive: true,
scales: {
xAxes: [{
stacked: false
}],
yAxes: [{
stacked: false
}]
}
}
});