<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/PointMark/init(x:y:)-9dswq",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts9PointMarkV1x1yAC14CoreFoundation7CGFloatVSg_AA14PlottableValueVyxGtcAA0G0Rzlufc"
  },
  "title" : "init(x:y:)"
}
-->

# init(x:y:)

Creates a point mark with fixed x position and plots values with y.

```
nonisolated init<Y>(x: CGFloat? = nil, y: PlottableValue<Y>) where Y : Plottable
```

## Parameters

`x`

The x position.  If `x` is `nil`, the bar will be centered horizontally by default.

`y`

The value plotted with y.

## Discussion

### Discussion

Use this initializer to plot a property to y:

```swift
Chart(data) {
    PointMark(
        y: .value("Weight", $0.weight)
    )
}
```

![Vertical point chart with weight plotted to the y-axis. There are 9 points at: 22, 24, 18, 22, 30, 27, 20, 14, 29.](images/com.apple.Charts/PointMarkSwift.PointMarkVerticalPointChart@2x.png)

For more background, see the first example used in [`PointMark`](/documentation/Charts/PointMark) which shows the structure that contains the `weight` property.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)