BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

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!

   

SOLVED:

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

   

@Bnerd  

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

   

Hacking with Swift is sponsored by Guardsquare

SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.

Learn more

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

Reply to this topic…

You need to create an account or log in to reply.

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.