<!--
{
  "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(xStart:xEnd:y:)-6jsoi",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts8RuleMarkV6xStart4xEnd1yAcA14PlottableValueVyxG_AI14CoreFoundation7CGFloatVSgtcAA0F0Rzlufc"
  },
  "title" : "init(xStart:xEnd:y:)"
}
-->

# init(xStart:xEnd:y:)

Creates a horizontal rule mark that plots values on its x interval.

```
nonisolated init<X>(xStart: PlottableValue<X>, xEnd: PlottableValue<X>, y: CGFloat? = nil) where X : Plottable
```

## Parameters

`xStart`

The value plotted with x start.

`xEnd`

The value plotted with x end.

`y`

The y position.   If `y` is `nil`, the rule will be centered vertically by default.

## Discussion

### Discussion

Use this initializer to create a horizontal rule at x positions from `xStart` to `xEnd` for a single y position:

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

![Horizontal rule chart with x-axis showing the month in the year 2020 starting with January and ending with December, and with y-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.LineSegmentMarkHorizontalSingleLineSegmentChart@2x.png)

See the second code example in [`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)