<!--
{
  "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:)-5gy50",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts8RuleMarkV1x6yStart4yEndAcA14PlottableValueVyxG_AHyq_GAJtcAA0F0RzAaKR_r0_lufc"
  },
  "title" : "init(x:yStart:yEnd:)"
}
-->

# init(x:yStart:yEnd:)

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

```
nonisolated init<X, Y>(x: PlottableValue<X>, yStart: PlottableValue<Y>, yEnd: PlottableValue<Y>) where X : Plottable, Y : Plottable
```

## Parameters

`x`

The value plotted with x.

`yStart`

The value plotted with y start.

`yEnd`

The value plotted with y end.

## Discussion

### Discussion

Use this initializer to create a vertical line at y positions from `yStart` to `yEnd` to an x position:

```swift
Chart(data) {
    RuleMark(
        x: .value("Pollen Source", $0.source),
        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, Grass, and Weeds. There are 4 rules. 2 for Trees 1 starting in January and going until the end of September and 1 spanning December, 1 for Grass starting in March and going until the end of August, and 1 for Weeds starting in April and going until the end of November.](images/com.apple.Charts/LineSegmentMarkSwift.LineSegmentMarkVerticalLineSegmentChart@2x.png)

See [`RuleMark`](/documentation/Charts/RuleMark) for the setup of the structure that contains 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)