init(x:yStart:yEnd:width:stacking:)
Creates a bar mark that plots a value on x with fixed y interval.
Declaration
nonisolated init<X>(x: PlottableValue<X>, yStart: CGFloat? = nil, yEnd: CGFloat? = nil, width: MarkDimension = .automatic, stacking: MarkStackingMethod = .standard) where X : PlottableParameters
- x:
The value plotted with x.
- yStart:
The y start position. If
yStartisnilthen the rectangle will start at the leading edge of the plotting area. - yEnd:
The y end position. If
yEndisnilthen the rectangle will end at the trailing edge of the plotting area. - width:
The bar width. If
widthisnil, the default bar size will be applied. - stacking:
The stacking method for the bars with the same categorical/date values. If
stackingisnil, the bars will not be stacked.
Discussion
Use this initializer to create a chart with a single horizontal bar:
Chart(data) {
BarMark(
x: .value("Profit", $0.profit)
)
.foregroundStyle(by: .value("Product Category", $0.productCategory))
}[Image]