One Logo Pool Ball
Charts · IOS API REFERENCE

ChartContent

protocol · iOS 16.0+ · SDK 27.1

@MainActor @preconcurrency protocol ChartContent

A type that represents the content that you draw on a chart. You build a ``Chart`` by adding instances that conform to the `ChartContent` protocol to the chart's `content` closure. The following example adds three explicit ``BarMark`` instances to a chart: Chart { BarMark( x: .value("Shape Type", "Cube"), y: .value("Total Count", 5) ) BarMark( x: .value("Shape Type", "Sphere"), y: .value("Total Count", 6) ) BarMark( x: .value("Shape Type", "Pyramid"), y: .value("Total Count", 4) ) } The chart draws marks that correspond to the instances that you specify: ![A bar chart with three vertical bars, all in the same color. The first is labeled Cube and has a value of 5. The second is labeled Sphere and has a value of 6. The third is labeled Pyramid and has a value of 4.](ChartContent-1-macOS) You can combine any number of marks or types of marks in a single chart by listing them individually as shown in the above example, wrapping them in a <doc://com.apple.documentation/documentation/SwiftUI/ForEach>, or any combination of these. For some mark types, like ``LineMark``, you can group the marks into series using the mark's `series` initialization parameter. ### Configure chart content The `ChartContent` protocol provides a set of modifiers that you use to configure the properties of chart content. These behave like SwiftUI view modifiers, except that they act on chart content rather than views. Any of the types that conform to the protocol can use these modifiers. For example, you can add the ``foregroundStyle(_:)`` modifier to the bar representing the number of spheres in the previous example to make it red: BarMark( x: .value("Shape Type", "Sphere"), y: .value("Total Count", 6) ) .foregroundStyle(.red) ![A bar chart with three vertical bars. The first and third bars are blue while the middle bar is red. The first is labeled Cube and has a value of 5. The second is labeled Sphere and has a value of 6. The third is labeled Pyramid and has a value of 4.](ChartContent-2-macOS)

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

41 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ChartContent.accessibilityLabel(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityLabel(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityLabel(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityLabel(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityValue(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityValue(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityValue(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityValue(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityIdentifier(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.accessibilityHidden(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.annotation(position:alignment:spacing:content:)

callback cannot propagate synchronous failure

ChartContent.annotation(position:alignment:spacing:content:)

callback cannot propagate synchronous failure

ChartContent.annotation(position:alignment:spacing:overflowResolution:content:)

callback cannot propagate synchronous failure

ChartContent.annotation(position:alignment:spacing:overflowResolution:content:)

callback cannot propagate synchronous failure

ChartContent.compositingLayer()

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.compositingLayer(style:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.mask(content:)

callback cannot propagate synchronous failure

ChartContent.foregroundStyle(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.foregroundStyle(by:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.alignsMarkStylesWithPlotArea(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.position(by:axis:span:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.opacity(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.clipShape(_:style:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.lineStyle(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.lineStyle(by:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.symbol(_:)

This declaration needs Swift generic type arguments. (no canonical witness for S)

ChartContent.symbol(by:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.symbol(symbol:)

callback cannot propagate synchronous failure

ChartContent.symbolSize(_:)

This protocol needs associated types that cannot yet cross the bridge.

ChartContent.symbolSize(_:)

This protocol needs associated types that cannot yet cross the bridge.

All Charts types →