Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

[FEATURE] Orientation / rotation option of Y scale title

Open joaobarcia opened this issue 6 years ago • 7 comments

I've checked the documentation, stack overflow questions and github issues and it does not seem to be possible to rotate scale/axis titles.

screenshot-2018-3-23 evisualizer

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!

joaobarcia avatar Mar 23 '18 14:03 joaobarcia

That's exactly what i am looking for. Would be great to get this to work.

Someone got a temporarily solution for this?

cuthulino avatar Mar 29 '18 10:03 cuthulino

@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 avatar Mar 29 '18 10:03 joaobarcia

@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)

cuthulino avatar Mar 29 '18 14:03 cuthulino

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.

myownzinger avatar Feb 21 '20 19:02 myownzinger

I have gotten a minimal working version as mentioned here: https://github.com/chartjs/Chart.js/issues/8345#issuecomment-1084405699

En1kay avatar Mar 31 '22 11:03 En1kay

@En1kay, did you get a chance to open a PR with your proposal?

joaomarcelofm avatar Jan 04 '24 10:01 joaomarcelofm

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)

En1kay avatar Jan 04 '24 14:01 En1kay