---
title: "init(_:id:content:)"
framework: charts
role: symbol
role_heading: Initializer
path: "charts/chart/init(_:id:content:)"
---

# init(_:id:content:)

Creates a chart composed of a series of marks.

## Declaration

```swift
nonisolated init<Data, ID, C>(_ data: Data, id: KeyPath<Data.Element, ID>, @ContentBuilder content: @escaping (Data.Element) -> C) where Content == ForEach<Data, ID, C>, Data : RandomAccessCollection, ID : Hashable, C : ChartContent
```

## Parameters

- `data`: A collection of data.
- `id`: A key path that represents a property of each data element that can act as a unique identifier for that element. Ensure that this property conforms to the doc://com.apple.documentation/documentation/Swift/Hashable protocol.
- `content`: The mark that the chart should draw for each element in the data collection.

## Discussion

Discussion This initializer wraps the data that you provide as input in an implicit ForEach structure. If you need to represent more than one series in your chart, use init(content:) instead.

## See Also

### Creating a chart

- [init(content:)](charts/chart/init(content:).md)
- [init(_:content:)](charts/chart/init(_:content:).md)
