[ad_1]

I want to change bar background, label font color and label font weight.
But only the bar background color works.

How can I change font-color and font-weight on click?

const backgroundColor = ['rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)','rgb(197,197,197)'];
const fontColor = ['rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)','rgb(153,153,153)'];
const fontWeight = [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400];          
const barChart = new Chart(
            document.getElementById("barChart"), {
            type: 'bar',
            data: {
                labels: ["jan", "fab", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"],
                datasets: [{
                    data: [8, 2, 3, 0, 5, 2, 2, 0, 0, 6, 10, 2],
                    backgroundColor: backgroundColor,
                    borderRadius: 6,
                    borderSkipped: false,
                    barThickness: 20,
                }]      
            },                                                                         
            options:{
                onClick: function(evt){
                    const points = barChart.getElementsAtEventForMode(evt, 'nearest', { intersect: true }, true);
                    if (points.length) {
                        const firstPoint = points[0];
                        for (let i=0; i<backgroundColor.length; i++) {
                            backgroundColor[i] = 'rgb(197,197,197)';
                            fontColor[i] = 'rgb(153,153,153)';
                            fontWeight[i] = 400;
                        }
                        backgroundColor[firstPoint.index] = '#2157e4';
                        fontColor[firstPoint.index] = 'rgb(32,32,32)';
                        fontWeight[firstPoint.index] = 600;

                        this.update();
                    }
                },

});

[ad_2]