Chart.js: [FEATURE] Orientation / rotation option of Y scale title

Created on 23 Mar 2018  ·  4Comments  ·  Source: chartjs/Chart.js

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!

enhancement

Most helpful comment

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

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings