<!--
{
  "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/chartBackground(alignment:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP6ChartsE15chartBackground9alignment7contentQrAA9AlignmentV_qd__AD10ChartProxyVctAaBRd__lF"
  },
  "title" : "chartBackground(alignment:content:)"
}
-->

# chartBackground(alignment:content:)

Adds a background to a view that contains a chart.

```
nonisolated func chartBackground<V>(alignment: Alignment = .center, @ViewBuilder content: @escaping (ChartProxy) -> V) -> some View where V : View
```

## Parameters

`alignment`

The alignment of the content.

`content`

The content of the background.

## Discussion

You can use this modifier to define a background view as a function of
the chart in the view. You can access the chart with the `ChartProxy` object
passed into the closure.

> Note: If `self` contains more than one chart, the chart proxy will refer
> to the first chart.

---

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)