<!--
{
  "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" : "Charts",
  "identifier" : "/documentation/Charts/RuleMark/init(x:yStart:yEnd:)-8iusl",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts8RuleMarkV1x6yStart4yEndAC14CoreFoundation7CGFloatVSg_AA14PlottableValueVyxGAMtcAA0I0Rzlufc"
  },
  "title" : "init(x:yStart:yEnd:)"
}
-->

# init(x:yStart:yEnd:)

Creates a vertical rule mark with a fixed x position and y interval encoding.

```
nonisolated init<Y>(x: CGFloat? = nil, yStart: PlottableValue<Y>, yEnd: PlottableValue<Y>) where Y : Plottable
```

## Parameters

`x`

The x position.   If `x` is `nil`, the rule will be centered horizontally by default.

`yStart`

The value plotted with y start.

`yEnd`

The value plotted with y end.

## Discussion

### Discussion

Use this initializer to create a vertical rule at y positions from `yStart` to `yEnd` for a single x position:

```swift
Chart(data) {
    RuleMark(
        yStart: .value("Start Date", $0.startDate),
        yEnd: .value("End Date", $0.endDate)
    )
}
```

![Vertical rule chart with y-axis showing the month in the year 2020 starting with January and ending with December, and with x-axis showing a pollen source: Trees. There are 2 rules. 1 starting in January and going until the end of September and 1 spanning December.](images/com.apple.Charts/LineSegmentMarkSwift.LineSegmentMarkVerticalSingleLineSegmentChart@2x.png)

See [`RuleMark`](/documentation/Charts/RuleMark) for the setup of the structure containing the `startDate`, `endDate`, and `source`
properties.

---

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)