Hello Apple SwiftUI / Swift Charts Engineering Team,
I am writing to report a layout regression regarding Swift Charts in iOS 27. The anchor property on AxisValueLabel has stopped honoring the .topLeading layout coordinate, whereas it functions perfectly in iOS 26.
Bug Description:
To prevent the first label on a bottom X-axis from clipping past the left screen edge, a .topLeading anchor is applied. In iOS 27, this specific anchor alignment is completely ignored. The chart falls back to a standard top-center alignment, causing the initial boundary label to clip off-screen.
Core Code Snippet to Reproduce:
struct XAxisAnchorBugView: View {
let dates = [
Calendar.current.date(from: DateComponents(year: 2026, month: 10, day: 1))!,
Calendar.current.date(from: DateComponents(year: 2026, month: 10, day: 2))!
]
var body: some View {
Chart(dates, id: .self) { date in
LineMark(x: .value("Date", date), y: .value("Value", 100))
}
.frame(height: 300)
.padding()
.chartXAxis {
AxisMarks(preset: .aligned, position: .bottom, values: .stride(by: .day, count: 1)) { value in
AxisTick()
let currentAnchor: UnitPoint = {
guard let currentDate = value.as(Date.self) else { return .top }
// BUG: .topLeading layout anchor parameter is completely ignored on iOS 27
return (currentDate == dates.first) ? .topLeading : .top
}()
AxisValueLabel(format: .dateTime.month(.abbreviated).day(), anchor: currentAnchor)
}
}
}
}
Steps to Reproduce:
Render an X-axis with a .bottom position.
Assign anchor: .topLeading strictly to the first axis element's label.
Run on an iOS 26 simulator (the first label anchors its top-left corner correctly, preventing edge clipping).
Run on an iOS 27 simulator (the .topLeading anchor is ignored, reverting to standard top-center alignment).
Expected Behavior:
AxisValueLabel should position its layout bounding box using the .topLeading anchor point when specified.
Actual Behavior:
The layout engine ignores the .topLeading parameter on iOS 27, causing the boundary text to shift left and clip.
Attachments:
I have attached Xcode Simulator screenshots demonstrating this regression:
Best regards,
Soumyajit Das