Chartjs-Chartjs: Overwrite plot y-axis integer labels to some string value

0πŸ‘

βœ…

To modify the ChartJs Y-axis label , instead of passing string to scaleLabel property we need to pass the closure function, which will modify the label text.

scaleLabel: function (value)
                {
                    var label = "";
                    switch (parseInt(value))
                    {
                        case 1:
                            label = "Slow";
                            break;
                        case 2:
                            label = "Avg.";
                            break;
                        case 3:
                            label = "Fast";
                            break;
                        case 4:
                            label = "Exp.";
                            break;

                    }
                    return label;
                }

enter image description here

This is undocumented feature of chartJs

Leave a comment