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

# init(x:yStart:yEnd:)

Creates a vertical rule mark with value plotted with x.

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

## Parameters

`x`

The value plotted with x.

`yStart`

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

`yEnd`

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

## Discussion

### Discussion

Use this initializer to create a vertical rule across a chart’s plotting area at an x position:

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

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

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