<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/chartXAxisLabel(_:position:alignment:spacing:)-4wvwq",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP6ChartsE15chartXAxisLabel_8position9alignment7spacingQrAA18LocalizedStringKeyV_AD18AnnotationPositionVAA9AlignmentVSg14CoreFoundation7CGFloatVSgtF"
  },
  "title" : "chartXAxisLabel(_:position:alignment:spacing:)"
}
-->

# chartXAxisLabel(_:position:alignment:spacing:)

Adds x axis label for charts in the view.

```
nonisolated func chartXAxisLabel(_ labelKey: LocalizedStringKey, position: AnnotationPosition = .automatic, alignment: Alignment? = nil, spacing: CGFloat? = nil) -> some View
```

## Parameters

`labelKey`

The key for the localized label string.

`position`

The position of the label.

`alignment`

The alignment of the label.

`spacing`

The spacing of the label from the axis markers.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)