Chartjs rotate text

Asked

Viewed 102 times

0

I would like to know, I have a text created with canvas in chartJS]. How to rotate the text, the same being vertical in the center of the line. I tried with Rotate, but the text disappeared from the chart.

EXAMPLE

https://jsfiddle.net/esb8nh6g/

1 answer

0

canvas has both Translate() and Rotate() methods that can help in this situation:

ctx.translate(xaxis.getPixelForValue(undefined, index) -16, yaxis.top + 5);
ctx.rotate(-90*Math.PI/180);
ctx.fillText("ROTATE", 0, 0);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.