Contents

chartScrollTargetBehavior(_:)

Sets the scroll behavior of the scrollable chart.

Declaration

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

Parameters

  • behavior:

    The chart scroll target behavior.

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