<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/ChartScrollTargetBehavior/valueAligned(unit:majorAlignment:limitBehavior:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift Charts",
      "Charts"
    ],
    "preciseIdentifier" : "s:6Charts25ChartScrollTargetBehaviorPAAE12valueAligned4unit14majorAlignment05limitE0AA05ValuegbcdE0Vqd___AA05MajorlJ0Vyqd__GSgAA0lg5LimitE0VtAIRszAA9PlottableRd__SjRd__lFZ"
  },
  "title" : "valueAligned(unit:majorAlignment:limitBehavior:)"
}
-->

# valueAligned(unit:majorAlignment:limitBehavior:)

Creates a scroll target behavior that aligns to values spaced at regular intervals along the scrollable axes.

```
static func valueAligned<P>(unit: P, majorAlignment: MajorValueAlignment<P>? = nil, limitBehavior: ValueAlignedLimitBehavior = .automatic) -> ValueAlignedChartScrollTargetBehavior where Self == ValueAlignedChartScrollTargetBehavior, P : Plottable, P : Numeric
```

## Parameters

`unit`

The alignment unit. When the user finishes a scroll gesture, the chart will snap to align to
the given unit or the end of the domain.

`majorAlignment`

The behavior for aligning to major values. When the user swipes on the chart, the chart will snap to the
next or previous major unit depending on the swipe direction. When enabled, the default major unit is a page.

`limitBehavior`

The scroll limit behavior.

## Discussion

Use this method to create a scroll behavior that aligns to
desired units.

```
Chart(data) {
    BarMark(
        x: .value("x", $0.x),
        y: .value("y", $0.y)
    )
}
.chartScrollableAxes(.horizontal)
.chartScrollTargetBehavior(.valueAligned(unit: 10))
```

The value aligned behavior can be set to align to major units on swipes. When enabled, the default major unit is a page and the
behavior on swipe is similar to the `.paged` behavior.

---

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)