Skip to content

JannikArndt/SwiftUI-Charts-Playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Comparison of Chart Libraries for SwiftUI


Read the entire blog post including images on jannikarndt.de!


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.

About

Demo-implementation of 5 different Chart Libraries in SwiftUI

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages