Contents

init(xStart:xEnd:y:)

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

Declaration

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

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

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

[Image]

See the first code example in RuleMark for the setup of the structure that contains the department and profit properties.