<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/Plottable",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts9PlottableP"
  },
  "title" : "Plottable"
}
-->

# Plottable

A type that can serve as data to plot in a chart.

```
protocol Plottable
```

## Overview

You create [`PlottableValue`](/documentation/Charts/PlottableValue) items from data that conforms to `Plottable`
using a method like [`value(_:_:)`](/documentation/Charts/PlottableValue/value(_:_:)-13lvv). You then use
those items as the values in a chart, like for the [`BarMark`](/documentation/Charts/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"
}
```

## Topics

### Supporting types

[`PrimitivePlottableProtocol`](/documentation/Charts/PrimitivePlottableProtocol)

A type that represents the primitive plottable types supported by the framework. Don’t use this
type directly.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)