---
title: "chartBackground(alignment:content:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/chartbackground(alignment:content:)"
---

# chartBackground(alignment:content:)

Adds a background to a view that contains a chart.

## Declaration

```swift
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

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.

## See Also

### Styles

- [chartForegroundStyleScale(_:)](swiftui/view/chartforegroundstylescale(_:).md)
- [chartForegroundStyleScale(domain:range:type:)](swiftui/view/chartforegroundstylescale(domain:range:type:).md)
- [chartForegroundStyleScale(domain:type:)](swiftui/view/chartforegroundstylescale(domain:type:).md)
- [chartForegroundStyleScale(domain:mapping:)](swiftui/view/chartforegroundstylescale(domain:mapping:).md)
- [chartForegroundStyleScale(mapping:)](swiftui/view/chartforegroundstylescale(mapping:).md)
- [chartForegroundStyleScale(range:type:)](swiftui/view/chartforegroundstylescale(range:type:).md)
- [chartForegroundStyleScale(type:)](swiftui/view/chartforegroundstylescale(type:).md)
- [chartPlotStyle(content:)](swiftui/view/chartplotstyle(content:).md)
