Swift Charts: How to Make Horizontal Bar Charts in iOS and SwiftUI

Master iOS 16 Swift Charts — Learn how to make a horizontal bar chart in 10 minutes.

Dario Radečić
Better iOS Development

--

Article thumbnail (image by author)

If you want to add great-looking charts to your iOS apps, I have good news for you — it has never been easier than in iOS 16. Swift Charts are now available and leverage the familiar SwiftUI syntax we all know and love. In the previous article, you learned how to create and style vertical bar charts, but are these a good option when you have a lot of columns? Well, no.

Horizontal bar charts are a much better option in this use case, and this article will teach you everything you must know to get started. We’ll start from scratch, create a new Xcode project, define the data model and the data, and start working on the chart from there. By the end, you’ll have a bar chart with gradient color fill, annotations, and custom axis labels.

Table of contents:

  • Horizontal Bar Chart Data Model
  • Why Should You Opt for a Horizontal Bar Chart Instead of a Vertical One
  • How to Create a Basic Horizontal Bar Chart in SwiftUI
  • Styling iOS Horizontal Bar Charts — Everything You Need to Know
  • Conclusion

--

--