I have some problems in configuring the data labels. I wanted to show its value, but it seems that these data labels cannot be changed nor be deleted as you can see in the image attached that I circled yellow, that’s the data label that cannot be changed. I have tried every possible way to change or delete it but it is still there and I don’t know why.
Please help me. This is the function for generating this chart:
function renderChart() {
// var ctx = document.getElementById('rocsChart').getContext('2d');
let data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agt', 'Sep', 'Okt', 'Nov', 'Des'],
datasets: [{
label: 'ROCS',
// type: 'bar',
data: [-3971030560.1713, -3658191029.3873, -7636333358.9906, 2550158674.6845],
backgroundColor: 'rgba(75, 192, 192, 0.5)',
yAxisID: 'test1'
},
{
label: 'ROCS%',
type: 'line',
data: [-13, -12, -26, -8],
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 2,
fill: false,
yAxisID: 'test2'
}
]
};
const options = {
scales: {
yAxes: [{
id: 'test1',
type: 'linear',
position: 'left',
ticks: {
callback: function(value, index, values) {
return value;
}
}
},
{
id: 'test2',
type: 'linear',
position: 'right',
ticks: {
callback: function(value, index, values) {
return value;
}
}
}]
},
plugins: {
datalabels: {
align: 'end',
anchor: 'end',
backgroundColor: function(context) {
return context.dataset.backgroundColor;
},
borderRadius: 4,
color: 'white',
formatter: function(value, context) {
return value;
}
}
},
tooltips: {
enabled: false
}
};
For added context, this is the plugins ive been using:
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<script src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-title"></script>
Thank you in advance.
I expecting that the data labels can be changed to the data values