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:
- ivanschuetz/SwiftCharts
 - denniscm190/stock-charts
 - spacenation/swiftui-charts
 - AppPear/ChartView
 - danielgindi/Charts
 
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
- URL: https://github.com/ivanschuetz/SwiftCharts
 - License: Apache 2
 - Maturity: 
  
- Created May 2015 
β  - ~2 backup contributors, 32 in total
 - Last big changes 2019 
π¬  - Last commit to main: 8 days ago 
π  
 - Created May 2015 
 
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
- URL: https://github.com/denniscm190/stock-charts
 - License: MIT
 - Maturity: 
  
- Created April 2021 
β²  - Single-dev-project 
π¨βπ»  - Ongoing development 
β  - Last commit to main: 20 days ago 
π  - Demo App: https://github.com/denniscm190/trades-demo
 
 - Created April 2021 
 
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
- URL: https://github.com/spacenation/swiftui-charts
 - License: MIT
 - Maturity 
  
- Created Nov 2019 
β  - Single-dev-project 
π¨βπ»  - Last big change in Oct 2020 
π¬  - 2 open PRs
 
 - Created Nov 2019 
 - Bug: Data is ordered in reverse
 - Naming conflict: This package uses the same name as (the much older) https://github.com/danielgindi/Charts. To import both, I forked it to https://github.com/JannikArndt/swiftui-charts, changed the name and cherry-picked the open PRs.
 
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
- URL: https://github.com/AppPear/ChartView
 - License: MIT
 - Maturity 
  
- Created continuously between Jun 2019 and today 
β  - Version 2 is currently in beta
 - Only small contributions from others
 
 - Created continuously between Jun 2019 and today 
 
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
- URL: https://github.com/danielgindi/Charts
 - License: Apache 2
 - Maturity 
  
- Created Mar 2015 
πΈ  - Ongoing maintenance by second dev
 - 4 devs with larger contributions
 
 - Created Mar 2015 
 
Supported Chart Types
- Bar Charts 
β (even horizontal, with every option you can think of) - Line Charts 
β  - Pie Charts 
β  
Code
- Bar Chart: https://github.com/JannikArndt/SwiftUI-Charts-Playground/blob/main/ChartsPlayground/Charts/ChartsBarChart.swift
 - Line Chart: https://github.com/JannikArndt/SwiftUI-Charts-Playground/blob/main/ChartsPlayground/Charts/ChartsLineChart.swift
 - Pie Chart: https://github.com/JannikArndt/SwiftUI-Charts-Playground/blob/main/ChartsPlayground/Charts/ChartsPieChart.swift
 
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.