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();
- Chartjs-My point annotation in Chart.js 3.3.2 won't render in my Django template. Making a realtime graph of temperature for my wood-fired pizza oven
- Chartjs-Chart.js not stacking chart
Source:stackexchange.com