Chart.js
Chart.js copied to clipboard
[FEATURE] Orientation / rotation option of Y scale title
I've checked the documentation, stack overflow questions and github issues and it does not seem to be possible to rotate scale/axis titles.
Expected Behavior
I would like "energia mensili kWh" to have the same orientation as "pico mensili"
Current Behavior
Each Y-Axis scale title has a different orientation and makes readability harder.
Possible Solution
Add an orientation or rotation property to 'scaleLabel' object.
Thanks!
That's exactly what i am looking for. Would be great to get this to work.
Someone got a temporarily solution for this?
@cuthulino , super hacky but I'm using http://www.fliptext.org/ to find the string which kind of looks like the inverted version of what I want and using it as the scale label :P
@joaobarcia ough^^ this solution looks really ugly ;)
I just searched a bit and found a solution if you want it for all your charts. When you use the Chart.bundle.js of version 2.7.2 just got to line 12459 and change 0.5 to -0.5.
For the devs:
Add default option rotate:false,
to scaleLabel:
and just multiplicate 1 or -1 with rotation value.
replace rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI
with rotation = (isLeft ? -0.5 * Math.PI : 0.5 * Math.PI) * (scaleLabel.rotate ? -1 : 1)
I'm also looking for something like this, but I'd like to just rotate the y-axis title by 90 degrees so that it is upright.
I have gotten a minimal working version as mentioned here: https://github.com/chartjs/Chart.js/issues/8345#issuecomment-1084405699
@En1kay, did you get a chance to open a PR with your proposal?
No I did not but @Drahakar seems to have solved the issue a simpler way with PR https://github.com/Drahakar/vireauvert/pull/114 . Please check if this solves your issue. Otherwise I could revisit my solution (running in production for 1 year now)