One Logo Pool Ball
Charts · IOS API REFERENCE

Plottable

protocol · iOS 16.0+ · SDK 27.1

protocol Plottable

A type that can serve as data to plot in a chart. You create ``PlottableValue`` items from data that conforms to `Plottable` using a method like ``PlottableValue/value(_:_:)-13lvv``. You then use those items as the values in a chart, like for the ``BarMark`` chart in the following example: ```swift BarMark( x: .value("Category", "A") y: .value("Value", 100) ) .foregroundStyle(by: .value("Series", "Series 1")) ``` You can create a custom plottable type by conforming it to this protocol. For example: ```swift // Make `SomeValue` conform to `Plottable` and act as a categorical value in Swift Charts. struct SomeValue: Plottable { var primitivePlottable: String { ... } init?(primitivePlottable: String) { ... } } ``` In addition, you can make an enum work as a categorical data value by using `String` as its raw value and conforming the type to Plottable. The string values will be used as localized string keys when the categories are displayed as text in a chart (for example, on an axis). ```swift enum Status: String, Plottable { case active = "Active" case inactive = "Inactive" } ```

Members (1)

get · iOS 16.0+

primitivePlottable

Swift declaration
var primitivePlottable: String { get }

Skipped declarations

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

Plottable.init(primitivePlottable:)

A protocol cannot be constructed directly.

All Charts types →