How to create a chart using Swift Charts and SwiftUI

Ale Patrón
3 min readMar 15, 2024

Back in 2022, Apple introduced Swift Charts at the yearly Worldwide Developers Conference. Swift Charts is a powerful framework that allows you create interactive data visualizations. In this tutorial, we’re going to build a simple bar chart to display the number and genres of books you’ve read per year.

Data

We can get started by creating a new SwiftUI project on Xcode. Next, we’ll add a struct that will represent a single bar, we’ll call it BookStat.

--

--