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

# init(xStart:xEnd:y:)

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

```
nonisolated init<X, Y>(xStart: PlottableValue<X>, xEnd: PlottableValue<X>, y: PlottableValue<Y>) where X : Plottable, Y : Plottable
```

## Parameters

`xStart`

The value plotted with x start.

`xEnd`

The value plotted with x end.

`y`

The value plotted with y.

## Discussion

### Discussion

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

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

![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, 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.LineSegmentMarkHorizontalLineSegmentChart@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)