I want to add charts to my SwiftUI iOS App, Zettl. For that, I am going to compare the following libraries:

Requirements

My needs are

  • bar charts for categorial data. Extra: I need images as labels.
  • line charts for time-scale data. With multiple lines. Bonus points if I don’t have to care about the time distribution, i.e. can enter timestamps and they are spread correctly.
  • pie charts for relative comparisons. Here, the magic lies in good annotations.

SwiftCharts

Supported Chart Types

  • Bar Charts βœ…
  • Line Charts βœ… (didn’t check)
  • Donut Charts βœ… (didn’t check)
  • more

Code

Result

  • integration of UIView in SwiftUI sucks
  • Docs don’t help a lot
  • Examples are very complex

Stock-Charts

Supported Chart Types

  • Bar Charts => as “Capsule” Charts, for one value only ❌
  • Line Charts: without axis, only for this one specific use-case πŸ†—
  • Pie Charts: ❌

Code

Result

  • Super easy to integrate
  • But very limited to this one use case
  • The code offers some good inspiration to base upon

SwiftUI Charts

Supported Chart Types

  • Bar Charts, also stacked, not no axis or labels 😬
  • Very simple line charts πŸ†—
  • No pie charts ❌

Code

Result

  • Easy to integrate
  • But quite buggy
  • No axis-options

AppPear/ChartView

Supported Chart Types

  • Bar Charts βœ… (no axis though)
  • Line Charts βœ… (with multiple lines, no axis)
  • Pie Charts βœ… (no labels)

Code

Result

  • Nice library for that particular style, but cannot be changed to view axis / labels / more things

danielgindi/Charts

Supported Chart Types

  • Bar Charts βœ… (even horizontal, with every option you can think of)
  • Line Charts βœ…
  • Pie Charts βœ…

Code

Result

  • By far the most comprehensive library
  • No docs, references the Android docs, but good amount of demos
  • Many third-party tutorials, for example this one that explains the integration into SwiftUI
  • The amount of options is a little overwhelming, and the defaults are insane, so you have to go through the options.

Conclusion

I was close to building my own version of the required charts, until I tried danielgindi/Charts. While it is a heavyweight, I will give it a shot.

You can try out the demo-app with all five libraries here: https://github.com/JannikArndt/SwiftUI-Charts-Playground.