Description
Okay so there's this beautiful library called MPAndroidChart by Philipp Jahoda which has become very popular amongst Android developers, and in the meanwhile there's no decent charting solution for iOS.
An amazing feature of this library now, for Android, iOS, tvOS and OSX, is the time it saves you when developing for both platforms, as the learning curve is singleton- it happens only once, and the code stays very similar so developers don't have to go around and re-invent the app to produce the same output with a different library. (And that's not even considering the fact that there's not really another good choice out there currently...)
Charts alternatives and similar libraries
Based on the "UI" category.
Alternatively, view Charts alternatives based on common mentions on social networks and blogs.
-
NVActivityIndicatorView
A collection of awesome loading animations -
Animated Tab Bar
:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion -
folding-cell
:octocat: 📃 FoldingCell is an expanding content cell with animation made by @Ramotion -
SwiftMessages
A very flexible message bar for iOS written in Swift. -
JTAppleCalendar
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable -
LTMorphingLabel
[EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift. -
FSPagerView
FSPagerView is an elegant Screen Slide Library. It is extremely helpful for making Banner View、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders. -
AMScrollingNavbar
Scrollable UINavigationBar that follows the scrolling of a UIScrollView -
SwipeCellKit
Swipeable UITableViewCell/UICollectionViewCell based on the stock Mail.app, implemented in Swift. -
Pagemenu
A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram) -
SwiftEntryKit
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps. -
TextFieldEffects
Custom UITextFields effects inspired by Codrops, built using Swift -
Macaw
Powerful and easy-to-use vector graphics Swift library with SVG support -
Scrollable-GraphView
An adaptive scrollable graph view for iOS to visualise simple discrete datasets. Written in Swift. -
PermissionScope
A Periscope-inspired way to ask for iOS permissions. -
SPPermission
Universal API for request permission and get its statuses. -
Material Components for iOS
[In maintenance mode] Modular and customizable Material Design UI components for iOS -
SideMenu
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less. -
Alerts Pickers
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date... -
ESTabBarController
:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie! -
Instructions
Create walkthroughs and guided tours (coach marks) in a simple way, with Swift. -
ActiveLabel
UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift -
NotificationBanner
The easiest way to display highly customizable in app notification banners in iOS -
TLYShyNavBar
Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars! -
PopupDialog
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style. -
SlideMenuControllerSwift
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift. -
PKHUD
A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8. -
Siren
Notify users when a new version of your app is available and prompt them to upgrade. -
DGElasticPullToRefresh
Elastic pull to refresh for iOS developed in Swift -
KMNavigationBarTransition
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically. -
StarWars.iOS
This component implements transition animation to crumble view-controller into tiny pieces. -
Whisper
:mega: Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside -
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift -
RazzleDazzle
A simple keyframe-based animation framework for iOS, written in Swift. Perfect for scrolling app intros. -
XLActionController
Fully customizable and extensible action sheet controller written in Swift -
CircleMenu
:octocat: ⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations. Swift UI library made by @Ramotion -
PaperOnboarding
:octocat: PaperOnboarding is a material design UI slider. Swift UI library by @Ramotion -
PagingMenuController
Paging view controller with customizable menu in Swift.
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Charts or a related project?
README
Version 4.0.0, synced to MPAndroidChart #f6a398b
Just a heads up: Charts 3.0 has some breaking changes. Please read the release/migration notes.
Another heads up: ChartsRealm is now in a separate repo. Pods is also now Charts
and ChartsRealm
, instead of ~Charts/Core
~ and ~Charts/Realm
~
One more heads up: As Swift evolves, if you are not using the latest Swift compiler, you shouldn't check out the master branch. Instead, you should go to the release page and pick up whatever suits you.
- Xcode 14 / Swift 5.7 (master branch)
- iOS >= 12.0 (Use as an Embedded Framework)
- tvOS >= 12.0
- macOS >= 10.13
Okay so there's this beautiful library called MPAndroidChart by Philipp Jahoda which has become very popular amongst Android developers, but there was no decent solution to create charts for iOS.
I've chosen to write it in Swift
as it can be highly optimized by the compiler, and can be used in both Swift
and ObjC
project. The demo project is written in ObjC
to demonstrate how it works.
An amazing feature of this library now, for Android, iOS, tvOS and macOS, is the time it saves you when developing for both platforms, as the learning curve is singleton- it happens only once, and the code stays very similar so developers don't have to go around and re-invent the app to produce the same output with a different library. (And that's not even considering the fact that there's not really another good choice out there currently...)
Having trouble running the demo?
ChartsDemo/ChartsDemo.xcodeproj
is the demo project for iOS/tvOSChartsDemo-OSX/ChartsDemo-OSX.xcodeproj
is the demo project for macOS- Make sure you are running a supported version of Xcode.
- Usually it is specified here a few lines above.
- In most cases it will be the latest Xcode version.
- Make sure that your project supports Swift 5.0
- Optional: Run
carthage checkout
in the project folder, to fetch dependencies (i.e testing dependencies).- If you don't have Carthage - you can get it here.
Usage
In order to correctly compile:
- Drag the
Charts.xcodeproj
to your project - Go to your target's settings, hit the "+" under the "Frameworks, Libraries, and Embedded Content" section, and select the Charts.framework
@import Charts
- When using Swift in an ObjC project:
- You need to import your Bridging Header. Usually it is "YourProject-Swift.h", so in ChartsDemo it's "ChartsDemo-Swift.h". Do not try to actually include "ChartsDemo-Swift.h" in your project :-)
- (Xcode 8.1 and earlier) Under "Build Options", mark "Embedded Content Contains Swift Code"
- (Xcode 8.2+) Under "Build Options", mark "Always Embed Swift Standard Libraries"
- When using Realm.io:
- Note that the Realm framework is not linked with Charts - it is only there for optional bindings. Which means that you need to have the framework in your project, and in a compatible version to whatever is compiled with Charts. We will do our best to always compile against the latest version.
- You'll need to add
ChartsRealm
as a dependency too.
3rd party tutorials
Video tutorials
- Chart in Swift - Setting Up a Basic Line Chart Using iOS Charts(Alex Nagy)
- Charts Framework in SwiftUI - Bar Chart (Stewart Lynch)
Blog posts
- Using Realm and Charts with Swift 3 in iOS 10 (Sami Korpela)
- Creating a Line Chart in Swift 3 and iOS 10 (Osian Smith)
- Beginning Set-up and Example Using Charts with Swift 3
- Creating a Radar Chart in Swift (David Piper)
- Plotting in IOS using Charts framework with SwiftUI (Evgeny Basisty)
- Set Up a Basic Bar Chart Using iOS-Charts (Penny Huang)
- iOS-Charts Tutorial: Highlight Selected Value With a Custom Marker (Penny Huang)
Want your tutorial to show here? Create a PR!
Troubleshooting
Can't compile?
- Please note the difference between installing a compiled framework from CocoaPods or Carthage, and copying the source code.
- Please read the Usage section again.
- Search in the issues
- Try to politely ask in the issues section
Other problems / feature requests
- Search in the issues
- Try to politely ask in the issues section
CocoaPods Install
Add pod 'Charts'
to your Podfile. "Charts" is the name of the library.
For Realm support, please add pod 'ChartsRealm'
too.
Note: is not the correct library, and refers to a different project by someone else.pod 'ios-charts'
Carthage Install
Charts now include Carthage prebuilt binaries.
github "danielgindi/Charts" == 4.1.0
github "danielgindi/Charts" ~> 4.1.0
In order to build the binaries for a new release, use carthage build --no-skip-current && carthage archive Charts
.
Swift Package Manager Install
Swift Package Manager
dependencies: [
.package(url: "https://github.com/danielgindi/Charts.git", .upToNextMajor(from: "4.1.0"))
]
3rd party bindings
Xamarin (by @Flash3001): iOS - GitHub/NuGet. Android - GitHub/NuGet.
Help
If you like what you see here, and want to support the work being done in this repository, you could:
- Contribute code, issues and pull requests
- Let people know this library exists (:fire: spread the word :fire:)
(You can buy me a beer, or you can buy me dinner :-)
Note: The author of MPAndroidChart is the reason that this library exists, and is accepting donations on his page. He deserves them!
Questions & Issues
If you are having questions or problems, you should:
- Make sure you are using the latest version of the library. Check the release-section.
- Study the Android version's Documentation-Wiki
- Search or open questions on stackoverflow with the
ios-charts
tag - Search known issues for your problem (open and closed)
- Create new issues (please :fire: search known issues before :fire:, do not create duplicate issues)
Features
Core features:
- 8 different chart types
- Scaling on both axes (with touch-gesture, axes separately or pinch-zoom)
- Dragging / Panning (with touch-gesture)
- Combined-Charts (line-, bar-, scatter-, candle-stick-, bubble-)
- Dual (separate) Axes
- Customizable Axes (both x- and y-axis)
- Highlighting values (with customizable popup-views)
- Save chart to camera-roll / export to PNG/JPEG
- Predefined color templates
- Legends (generated automatically, customizable)
- Animations (build up animations, on both x- and y-axis)
- Limit lines (providing additional information, maximums, ...)
- Fully customizable (paints, typefaces, legends, colors, background, gestures, dashed lines, ...)
- Plotting data directly from Realm.io mobile database (here)
Chart types:
Screenshots are currently taken from the original repository, as they render exactly the same :-)
- LineChart (with legend, simple design)
LineChart (with legend, simple design)
LineChart (cubic lines)
LineChart (gradient fill)
Combined-Chart (bar- and linechart in this case)
BarChart (with legend, simple design)
- BarChart (grouped DataSets)
- Horizontal-BarChart
- PieChart (with selection, ...)
- ScatterChart (with squares, triangles, circles, ... and more)
- CandleStickChart (for financial data)
- BubbleChart (area covered by bubbles indicates the value)
- RadarChart (spider web chart)
Documentation
Currently there's no need for documentation for the iOS/tvOS/macOS version, as the API is 95% the same as on Android.
You can read the official MPAndroidChart documentation here: Wiki
Or you can see the Charts Demo project in both Objective-C and Swift (ChartsDemo-iOS, as well as macOS ChartsDemo-macOS) and learn the how-tos from it.
Special Thanks
Goes to @liuxuan30, @petester42 and @AlBirdie for new features, bugfixes, and lots and lots of involvement in our open-sourced community! You guys are a huge help to all of those coming here with questions and issues, and I couldn't respond to all of those without you.
Our amazing sponsors
Debricked: Use open source securely
License
Copyright 2016 Daniel Cohen Gindi & Philipp Jahoda
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*Note that all licence references and agreements mentioned in the Charts README section above
are relevant to that project's source code only.