init(xStart:xEnd:y:height:stacking:)
Creates a bar mark that plots values on y with fixed x interval.
Declaration
nonisolated init<Y>(xStart: CGFloat? = nil, xEnd: CGFloat? = nil, y: PlottableValue<Y>, height: MarkDimension = .automatic, stacking: MarkStackingMethod = .standard) where Y : PlottableParameters
- xStart:
The x start position. If
xStartisnilthen the rectangle will start at the leading edge of the plotting area. - xEnd:
The x end position. If
xStartisnilthen the rectangle will end at the trailing edge of the plotting area. - y:
The value plotted with y.
- height:
The bar height. If
heightisnil, 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 vertical bar:
Chart(data) {
BarMark(
y: .value("Profit", $0.profit)
)
.foregroundStyle(by: .value("Product Category", $0.productCategory))
}[Image]