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
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.
- 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 👍
- Bar Charts ✅
- Line Charts ✅ (didn't check)
- Donut Charts ✅ (didn't check)
- more
- integration of UIView in SwiftUI sucks
- Docs don't help a lot
- Examples are very complex
- 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
- Bar Charts => as "Capsule" Charts, for one value only ❌
- Line Charts: without axis, only for this one specific use-case 🆗
- Pie Charts: ❌
- Super easy to integrate
- But very limited to this one use case
- The code offers some good inspiration to base upon
- 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
- 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.
- Bar Charts, also stacked, not no axis or labels 😬
- Very simple line charts 🆗
- No pie charts ❌
- Easy to integrate
- But quite buggy
- No axis-options
- 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
- Bar Charts ✅ (no axis though)
- Line Charts ✅ (with multiple lines, no axis)
- Pie Charts ✅ (no labels)
- Nice library for that particular style, but cannot be changed to view axis / labels / more things
- URL: https://github.com/danielgindi/Charts
- License: Apache 2
- Maturity
- Created Mar 2015 🕸
- Ongoing maintenance by second dev
- 4 devs with larger contributions
- Bar Charts ✅ (even horizontal, with every option you can think of)
- Line Charts ✅
- Pie Charts ✅
- 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
- 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.
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.