Chartjs-Hide y-axis without hiding grid in chart.js

0👍

You can create a custom tick callback that just returns an empty string:

const chart = new Chart(ctx, {
    type: 'line',
    data: data,
    options: {
        scales: {
            y: {
                ticks: {
                    callback: function(value, index, ticks) {
                        return '';
                    }
                }
            }
        }
    }
});

0👍

You can also disable ticks and drawTicks in your grid:

const chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
    scales: {
        y: {
            grid: {
              drawTicks: false
            },
            ticks: {
              display: false
            }
        }
    }
}

});

Leave a comment