---
title: "chartScrollTargetBehavior(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/chartscrolltargetbehavior(_:)"
---

# chartScrollTargetBehavior(_:)

Sets the scroll behavior of the scrollable chart.

## Declaration

```swift
nonisolated func chartScrollTargetBehavior(_ behavior: some ChartScrollTargetBehavior) -> some View

```

## Parameters

- `behavior`: The chart scroll target behavior.

## Discussion

Discussion Use this method to control how the chart scrolls and aligns when the user finishes scrolling. The example below sets the scroll target behavior to align to the values in the chart. When the user finishes scrolling, the chart will settle to align with the values in the chart. Chart(data) {     BarMark(         x: .value("x", $0.x),         y: .value("y", $0.y)     ) } .chartScrollableAxes(.vertical) .chartYVisibleDomain(length: 10) .chartScrollTargetBehavior(.valueAligned(unit: 1))

## See Also

### Scrolling

- [chartScrollPosition(initialX:)](swiftui/view/chartscrollposition(initialx:).md)
- [chartScrollPosition(initialY:)](swiftui/view/chartscrollposition(initialy:).md)
- [chartScrollPosition(x:)](swiftui/view/chartscrollposition(x:).md)
- [chartScrollPosition(y:)](swiftui/view/chartscrollposition(y:).md)
- [chartScrollableAxes(_:)](swiftui/view/chartscrollableaxes(_:).md)
