Chartjs-Javascript and chart.js, how to add euro currency to y label

1πŸ‘

βœ…

In order to add custom label, you should attach a callback as below :

var chart = new Chart(ctx, {
    type: 'line',
    data: data,
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    // Include a dollar sign in the ticks
                    callback: function(value, index, values) {
                        return '$' + value;
                    }
                }
            }]
        }
    }
});

Important thing to remember here is that, if the callback returns null or undefined, the associated grid line will be hidden

Leave a comment