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

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

Creates a rectangle mark that plots values on x and has a fixed y interval.

## Declaration

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

## Discussion

Discussion x: The value plotted with x. width: The rectangle width.  If width is 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. 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. Discussion Use this initializer to map an x position to a rectangle for each data element. Optionally, specify the width, yStart position, or yEnd positions of the rectangles. The example below omits the optional width, yStart, and yEnd parameters and uses a number scale starting at (0,0) and ending at (6,6). The rectangle has the coordinates: (0,0), (0,6), (3,6), (3,0). Chart(data) {     RectangleMark(         x: .value("Rect X", 3)     )     .opacity(0.2)

PointMark(         x: .value("X", $0.x),         y: .value("Y", $0.y)     ) }

## See Also

### Creating a rectangle mark

- [init(x:yStart:yEnd:width:)](charts/rectanglemark/init(x:ystart:yend:width:)-vh2x.md)
- [init(xStart:xEnd:y:height:)](charts/rectanglemark/init(xstart:xend:y:height:)-27222.md)
- [init(xStart:xEnd:y:height:)](charts/rectanglemark/init(xstart:xend:y:height:)-4x46i.md)
- [init(xStart:xEnd:yStart:yEnd:)](charts/rectanglemark/init(xstart:xend:ystart:yend:)-1qbzg.md)
- [init(xStart:xEnd:yStart:yEnd:)](charts/rectanglemark/init(xstart:xend:ystart:yend:)-5682c.md)
- [init(xStart:xEnd:yStart:yEnd:)](charts/rectanglemark/init(xstart:xend:ystart:yend:)-5cbgh.md)
- [init(xStart:xEnd:yStart:yEnd:)](charts/rectanglemark/init(xstart:xend:ystart:yend:)-6jeka.md)
- [init(x:y:width:height:)](charts/rectanglemark/init(x:y:width:height:).md)
- [init(x:y:z:)](charts/rectanglemark/init(x:y:z:).md)
