LAST CHANCE: 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!

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 Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free 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.