[Chartjs]-Y axis set custom value using chart.js

3👍

Ok this answer is late, but for anyone who is facing this issue.
In order to change the y-axis label, you can use a callback in the ticks object of the chart options. You can specify a string that is to be returned for each y-axis point.

Here is a sample code for the requirement in the question:

options: {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true,

                            min: 0,
                            max: 4,
                            stepSize: 1,
                            callback: function (label, index, labels) {
                                switch (label) {
                                    case 0:
                                        return ' ';
                                    case 1:
                                        return '<5 M';
                                    case 2:
                                        return '>5 M';
                                    case 3:
                                        return '<30 M';
                                    case 4:
                                        return '>30 M';

                                }
                        }
                    }
                    }
                ]
                }

            }

Leave a comment