init(x:y:width:height:stacking:)
Creates a bar mark that plots values with x and y.
Declaration
nonisolated init<X, Y>(x: PlottableValue<X>, y: PlottableValue<Y>, width: MarkDimension = .automatic, height: MarkDimension = .automatic, stacking: MarkStackingMethod = .standard) where X : Plottable, Y : PlottableParameters
- x:
The value plotted with x.
- y:
The value plotted with y.
- width:
The bar width. If
widthisnil, the default bar size will be applied. - 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 one or more bars. For horizontal bars, plot categories or dates with y and numbers with x. For vertical bars, plot categories or dates with x and numbers with y:
Chart(data) {
BarMark(
x: .value("Department", $0.department),
y: .value("Profit", $0.profit)
)
}[Image]