How Can I Change the Y-axis labels to be shown as strings other than number in Chart.js?

๐Ÿ‘:0

Use this example from their documentation, instead of returning a dollar sign + value return: (value/1000 + โ€˜Kโ€™)

options: {
        scales: {
            yAxes: [{
                ticks: {
                    // Include a K in the ticks
                    callback: function(value, index, values) {
                        return (Number.parseInt(value)/1000) + 'K';
                    }
                }
            }]
        }
    }

https://www.chartjs.org/docs/latest/axes/labelling.html#creating-custom-tick-formats

Leave a comment