danielgindi /Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.

★ 27,966⑂ 5,980
SwiftCreated 2015-03-20
27,966
stars
+-5+-7+-22
5,980
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions

README

Version 4.0.0, synced to MPAndroidChart f6a398b

!alt tag

 !Supported Platforms   

 Just a heads up: Charts 5.0 has some breaking changes. Charts has now been renamed DGCharts to prevent conflicts with Apple's new Swift Charts. Please read the release/migration notes.

 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/tvOS
- ChartsDemo-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:

1. Drag the DGCharts.xcodeproj to your project
2. Go to your target's settings, hit the "+" under the "Frameworks, Libraries, and Embedded Content" section, and select the DGCharts.framework
3. @import DGCharts
4. 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"

5. 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 DGCharts. We will do our best to always compile against the latest version.
   - You'll need to a

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON