---
title: "init(x:yStart:yEnd:width:stacking:)"
framework: charts
role: symbol
role_heading: Initializer
path: "charts/barmark/init(x:ystart:yend:width:stacking:)"
---

# init(x:yStart:yEnd:width:stacking:)

Creates a bar mark that plots a value on x with fixed y interval.

## Declaration

```swift
nonisolated init<X>(x: PlottableValue<X>, yStart: CGFloat? = nil, yEnd: CGFloat? = nil, width: MarkDimension = .automatic, stacking: MarkStackingMethod = .standard) where X : Plottable
```

## Parameters

- `x`: The value plotted with x.
- `yStart`: The y start position. If yStart is nil then the rectangle will start at the leading edge of the plotting area.
- `yEnd`: The y end position. If yEnd is nil then the rectangle will end at the trailing edge of the plotting area.
- `width`: The bar width. If width is nil, the default bar size will be applied.
- `stacking`: The stacking method for the bars with the same categorical/date values. If stacking is nil, the bars will not be stacked.

## Discussion

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)) }

## See Also

### Creating a bar mark

- [init(x:yStart:yEnd:width:)](charts/barmark/init(x:ystart:yend:width:).md)
- [init(xStart:xEnd:y:height:)](charts/barmark/init(xstart:xend:y:height:).md)
- [init(x:y:width:height:stacking:)](charts/barmark/init(x:y:width:height:stacking:).md)
- [init(xStart:xEnd:yStart:yEnd:)](charts/barmark/init(xstart:xend:ystart:yend:)-98wo9.md)
- [init(xStart:xEnd:yStart:yEnd:)](charts/barmark/init(xstart:xend:ystart:yend:)-7541n.md)
- [init(x:y:width:height:stacking:)](charts/barmark/init(x:y:width:height:stacking:).md)
- [init(xStart:xEnd:y:height:stacking:)](charts/barmark/init(xstart:xend:y:height:stacking:).md)
