<!--
{
  "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/ChartContent/position(by:axis:span:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift Charts",
      "Charts"
    ],
    "preciseIdentifier" : "s:6Charts12ChartContentPAAE8position2by4axis4spanQrAA14PlottableValueVyqd__G_7SwiftUI4AxisOSgAA13MarkDimensionVtAA0H0Rd__lF"
  },
  "title" : "position(by:axis:span:)"
}
-->

# position(by:axis:span:)

Represents data using position.

```
nonisolated func position<P>(by value: PlottableValue<P>, axis: Axis? = nil, span: MarkDimension = .automatic) -> some ChartContent where P : Plottable
```

## Parameters

`value`

The data used for positioning marks.

`axis`

The axis to position marks along. Set this to `nil`
to use a default configuration.

`span`

The span of the positioned marks. Use this to control
the total amount space available to the marks.

## Discussion

The code below creates a grouped bar chart that positions
marks with the same “product” along the horizontal axis by their “type”.

```
Chart(cars) {
    BarMark(
        x: .value("product", $0.product),
        y: .value("price", $0.price)
    )
    .position(by: .value("type", $0.type), axis: .horizontal)
}
```

---

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)