Contents

position(by:axis:span:)

Represents data using position.

Declaration

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

See Also

Encoding data into mark characteristics