Contents

init(x:y:stacking:)

Creates an area mark using the specified horizontal and vertical positions.

Declaration

nonisolated init<X, Y>(x: PlottableValue<X>, y: PlottableValue<Y>, stacking: MarkStackingMethod = .standard) where X : Plottable, Y : Plottable

Parameters

  • x:

    The horizontal position for the mark.

  • y:

    The vertical position for the mark.

  • stacking:

    The way in which the chart stacks area regions. The default is Standard.

Discussion

You can use this initializer to create a basic area chart:

Chart(cheeseburgerCost) { cost in
    AreaMark(
        x: .value("Date", cost.date),
        y: .value("Price", cost.price)
    )
}

The resulting chart automatically scales and labels the axes based on the data, and fills the area under the data points with a default color:

[Image]

See Also

Creating an area mark