init(xStart:xEnd:y:height:)
Creates a rectangle mark with an x interval encoding and a y encoding.
Declaration
nonisolated init<X, Y>(xStart: PlottableValue<X>, xEnd: PlottableValue<X>, y: PlottableValue<Y>, height: MarkDimension = .automatic) where X : Plottable, Y : PlottableParameters
- xStart:
The value plotted with x start.
- xEnd:
The value plotted with x end.
- y:
The value plotted with y.
- height:
The rectangle height. If
heightis not specified, then 70% of the step size will be used. If there is no step size a default height (in pts) will be used.
Discussion
Use this initializer to map the x start, x end and y position to a rectangle for each data element. Optionally, specify the height of the rectangles.
The example below omits the optional height parameter and uses a number scale starting at (0,0) and ending at (6,6). The rectangle has the coordinates: (2,0), (2,4), (4,4), (4,0).
Chart(data) {
RectangleMark(
xStart: .value("Rect xStart", 2),
xEnd: .value("Rect xEnd", 4),
y: .value("Rect Y", 4)
)
.opacity(0.2)
PointMark(
x: .value("X", $0.x),
y: .value("Y", $0.y)
)
}[Image]