init(xStart:xEnd:yStart:yEnd:)
Creates a rectangle mark with x and y interval encodings.
Declaration
nonisolated init<X, Y>(xStart: PlottableValue<X>, xEnd: PlottableValue<X>, yStart: PlottableValue<Y>, yEnd: PlottableValue<Y>) where X : Plottable, Y : PlottableParameters
- xStart:
The value plotted with x start.
- xEnd:
The value plotted with x end.
- yStart:
The value plotted with y start.
- yEnd:
The value plotted with y end.
Discussion
Use this initializer to map the x start, x end, y start, and y end position to a rectangle for each data element.
The example below uses a number scale starting at (0,0) and ending at (6,6). The rectangle has the coordinates: (2,2), (2,4), (4,4), (4,2).
Chart(data) {
RectangleMark(
xStart: .value("Rect xStart", 2),
xEnd: .value("Rect xEnd", 4),
yStart: .value("Rect yStart", 2),
yEnd: .value("Rect yEnd", 4)
)
.opacity(0.2)
PointMark(
x: .value("X", $0.x),
y: .value("Y", $0.y)
)
}[Image]