TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: Chart X axis - changing the angle of display

Forums > SwiftUI

Hello good folks,

Another charts question i'm afraid.

I have a chart with 12 months of data. It's displayed in portrait mode so the X axis labels are not fully displayed, for example I see Feb... instead of Feb-22.

I would therefore like to change the angle of display to 45 degrees for the X axis.

I can't see how/if that can be done.

Any clues?

Thank you!

2      

SOLVED:

 .chartXAxis(content: {
        AxisMarks { value in
            AxisValueLabel {
                if let month = value.as(String.self) {
                    Text(month)
                        .rotationEffect(Angle(degrees: 60))
                }
            }
        }
    })

2      

@Bnerd  

@Flaneur Thank you!!! I was breaking my head!!!

2      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.