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

# init(xStart:xEnd:y:)

Creates a horizontal rule mark that plots a value on y.

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

## Parameters

`xStart`

The x start position. If `xStart` is `nil` the rule will start at the leading edge of the plotting area.

`xEnd`

The x end position. If `xEnd` is `nil` the rule will end at the trailing edge of the plotting area.

`y`

The value plotted with y.

## Discussion

### Discussion

Use this initializer to create a horizontal rule across a chart’s plotting area at a y position:

```swift
Chart {
    ForEach(data) {
        BarMark(
            x: .value("Department", $0.department),
            y: .value("Profit", $0.profit)
        )
    }
    RuleMark(y: .value("Break Even Threshold", 9000))
        .foregroundStyle(.red)
}
```

![Vertical bar chart with x-axis showing department categories Production, Marketing, Finance, and R&D, and with y-axis ranging from 0 to 15000. There are 3 bars: Production 15000, Marketing 8000, Finance 10000. A horizontal rule mark at 9000 shows the break even threshold.](images/com.apple.Charts/LineSegmentMarkSwift.LineSegmentMarkBarChartWithHorizontalLineSegmentMark@2x.png)

See the first code example in [`RuleMark`](/documentation/Charts/RuleMark) for the setup of the structure that contains the `department` and `profit` 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)