Chartjs-How to align ticks label in chartJS 3.x?

0👍

After some research i adapted the method showned here to works with ChartJS 3.x:

plugins: [{
afterDraw: function (c) {
    var yScale = c.scales['y'];
    yScale.ticks.forEach(function (o, i) {
        // top tick label indent
        var yT_O = yScale.getPixelForTick(i) - 9;
        // left tick label indent
        var xT_O = c.width - 35;

        c.ctx.fillStyle = "#707070"
        c.ctx.fillText(o.label, xT_O, yT_O);
    });
}

}]

Actually i’m not sure this is the best plugin event where do that.
I also had to put "display: false" on the ticks options in order to hide the originals tick labels.

Leave a comment