init(x:y:width:height:)
Creates a rectangle that plots values with x and y.
Declaration
nonisolated init<X, Y>(x: PlottableValue<X>, y: PlottableValue<Y>, width: MarkDimension = .automatic, height: MarkDimension = .automatic) where X : Plottable, Y : PlottableParameters
- x:
The value plotted with x.
- y:
The value plotted with y.
- width:
The rectangle width. If
widthis not specified, then 70% of the step size will be used. If there is no step size a default width (in pts) will be used. - 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 an x and y position to a rectangle for each data element. Optionally, specify the width or height of the rectangles.
The example below omits the optional width and height parameters and uses a number scale starting at (0,0). The rectangle has the coordinates: (0,0), (0,3), (3,0), (3,3).
Chart(data) {
RectangleMark(
x: .value("Rect X", 3),
y: .value("Rect Y", 3)
)
.opacity(0.2)
PointMark(
x: .value("X", $0.x),
y: .value("Y", $0.y)
)
}[Image]