init(x:yStart:yEnd:)
Creates a vertical rule mark with value plotted with x.
Declaration
nonisolated init<X>(x: PlottableValue<X>, yStart: CGFloat? = nil, yEnd: CGFloat? = nil) where X : PlottableParameters
- x:
The value plotted with x.
- yStart:
The y start position. If
yStartisnilthe rule will start at the leading edge of the plotting area. - yEnd:
The y end position. If
yEndisnilthe rule will end at the trailing edge of the plotting area.
Discussion
Use this initializer to create a vertical rule across a chart’s plotting area at an x position:
Chart {
ForEach(data) {
BarMark(
x: .value("Profit", $0.profit),
y: .value("Department", $0.department)
)
}
RuleMark(x: .value("Break Even Threshold", 9000))
.foregroundStyle(.red)
}[Image]
See the first code example in RuleMark for the setup of the structure that contains department and profit properties.