Chart3D
struct · iOS 26.0+ · SDK 27.1
@MainActor @preconcurrency struct Chart3D<Content> where Content : Chart3DContentA SwiftUI view that displays interactive 3D charts and visualizations. Use `Chart3D` to create three-dimensional data visualizations with compatible mark types. To add content to your chart, use the 3D-only ``SurfacePlot`` or the 3D initializers of ``PointMark``, ``RuleMark``, and ``RectangleMark``. For example, you can use a ``SurfacePlot`` to visualize a 3D surface for the function `y = cos(2 * x) * sin(2 * x)`: ```swift Chart3D { SurfacePlot(x: "x", y: "y", z: "z") { x, z in sin(2 * x) * cos(2 * z) } } ``` You can also use the 3D initializers for `PointMark` ``PointMark/init(x:y:z:)``, `RuleMark` ``RuleMark/init(x:y:z:)``, `RectangleMark` ``RectangleMark/init(x:y:z:)`` to plot 3D visualizations of your data. For example, suppose you have an array of `Penguin` structures that define datapoints composed of `beakLength`, `weight` `flipperLength`: ```swift struct Penguin: Identifiable { let id: Int let flipperLength: Double let weight: Double let beakLength: Double } let penguins: [Penguin] = [ Penguin(id: 0, flipperLength: 197, weight: 4.2, beakLength: 59), Penguin(id: 1, flipperLength: 220, weight: 4.7, beakLength: 48), Penguin(id: 2, flipperLength: 235, weight: 5.8, beakLength: 42), ... ] ``` You can also use the 3D initializer of`PointMark` ``PointMark/init(x:y:z:)`` to represent the `flipperLength` property as the x value, the `weight` property as the y value, and the `beakLength` property as the z value: ```swift Chart3D(penguins) { PointMark( x: .value("Flipper Length (mm)", $0.flipperLength), y: .value("Weight (kg)", $0.weight), z: .value("Beak Length (mm)", $0.beakLength) ) } ``` ### Customizing interactivity To make your 3D Chart interactive, declare a `@State` property of type ``Chart3DPose`` and pass it as a binding to the ``chart3DPose(_:)-(Binding<Chart3DPose>)`` view modifier: ```swift @State private var pose: Chart3DPose = .default var body: some View { Chart3D(penguins) { PointMark( x: .value("Flipper Length (mm)", $0.flipperLength), y: .value("Weight (kg)", $0.weight), z: .value("Beak Length (mm)", $0.beakLength) ) } .chart3DPose($pose) } ``` On available platforms, you can use the ``chart3DCameraProjection(_:)`` modifier to switch from orthographic to perspective projection. ```swift Chart3D(penguins) { ... } .chart3DCameraProjection(.perspective) ```
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
Chart3D.init(content:)
This declaration needs Swift generic type arguments. (no canonical witness for Content)
Chart3D.body
This protocol needs associated types that cannot yet cross the bridge.
Chart3D.init(_:content:)
This declaration needs Swift generic type arguments. (no canonical witness for Data)
Chart3D.init(_:id:content:)
This declaration needs Swift generic type arguments. (no canonical witness for Data)