Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chart.js - How to remove percentage data labels?

I'm using Chart.js and I want to remove labels with percentage marked with red circle on image below.

Example

I'm using this code to produce this chart:

const options = {
    responsive: true,
    title: {
        display: false
    },
    legend: {
        display: false
    },
    tooltips: {
        mode: 'index',
        intersect: true
    },
    scales: {
        yAxes: [{
            type: 'linear',
            position: 'left',
            id: 'y-axis-1'
        }, {
            type: 'linear',
            position: 'right',
            id: 'y-axis-2',
            gridLines: {
                drawOnChartArea: false
            }
        }],
    }
};

new Chart(document.getElementById('originalThirdChart').getContext('2d'), {
    type: 'bar',
    data: data,
    options: options
});

How can I do this? Thanks in advance!

like image 544
tpszer Avatar asked Oct 20 '25 14:10

tpszer


1 Answers

If you want to remove only the percentages, just add this line in your options

labels: { render: () => {} }

It will look like:

options: { 
        plugins: {
          labels: {
            render: () => {}
          }
        }
    }
like image 117
Sparfel Avatar answered Oct 22 '25 02:10

Sparfel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!