Chartjs-Chart js -data on chart in rotated form

2👍

After rotating, the axes of the canvas are at an angle. If you try to use fillText with some x and y, they will be along the rotated axes, which is why the text is not in the correct position. Try instead to first translate to the correct position, then rotate, then fillText with x = y = 0.
This will place the text in the correct position, and then rotate it on the spot.

Also, you should call save before transforming the context’s matrix.

Try the following:

ctx.save();
ctx.translate(bar._model.x, bar._model.y);
ctx.rotate(-Math.PI / 4);
ctx.fillText("" + data + ",", 0, 0);
ctx.restore();

Leave a comment