• Stars
    star
    27,274
  • Rank 668 (Top 0.02 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Version 4.0.0, synced to MPAndroidChart #f6a398b

alt tag Supported Platforms Releases Latest pod release Carthage compatible Build Status codecov Join the chat at https://gitter.im/danielgindi/Charts

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"
  1. 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 add ChartsRealm as a dependency too.

3rd party tutorials

Video tutorials

Blog posts

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 'DGCharts' to your Podfile. "DGCharts" is the name of the library.
For Realm support, please add pod 'ChartsRealm' too.

Note: pod 'ios-charts' is not the correct library, and refers to a different project by someone else.

Carthage Install

DGCharts now include Carthage prebuilt binaries.

github "danielgindi/Charts" == 5.1.0
github "danielgindi/Charts" ~> 5.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: "5.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:)
  • Donate (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 🔥 search known issues before 🔥, 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) alt tag

  • LineChart (with legend, simple design) alt tag

  • LineChart (cubic lines) alt tag

  • LineChart (gradient fill) alt tag

  • Combined-Chart (bar- and linechart in this case) alt tag

  • BarChart (with legend, simple design)

alt tag

  • BarChart (grouped DataSets)

alt tag

  • Horizontal-BarChart

alt tag

  • PieChart (with selection, ...)

alt tag

  • ScatterChart (with squares, triangles, circles, ... and more)

alt tag

  • CandleStickChart (for financial data)

alt tag

  • BubbleChart (area covered by bubbles indicates the value)

alt tag

  • RadarChart (spider web chart)

alt tag

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

debricked

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.

More Repositories

1

ChartsRealm

A Realm.io module for Charts
Objective-C
131
star
2

drunken-danger-zone

All kinds of iOS / ObjC helper classes. The name of the repository - was amazingly suggested by GitHub :-)
65
star
3

knex-schema-builder

A schema builder module for knex.js, handles schema initialization and migration
JavaScript
49
star
4

app-redirect

Handles redirecting to the native app / app store on iOS and Android
JavaScript
41
star
5

node-csv-reader

A CSV stream reader, with many many features, and ability to work with the largest datasets
JavaScript
35
star
6

node-autodetect-decoder-stream

An iconv-lite stream that autodetects the encoding and fallbacks to a specified fallback encoding.
JavaScript
31
star
7

android-helpers

A collection of helper classes for android
Kotlin
29
star
8

jquery.dgtable

A jQuery high-performance table for web-apps
JavaScript
28
star
9

node-python-struct

Packs/Unpacks/Measures structs according to Python's `struct` format
JavaScript
27
star
10

UIRefreshControl-UITableView

An extension to UIRefreshControl to setup a UIRefreshControl with a UITableView (a bugfix). (iOS / ObjC)
Objective-C
22
star
11

rollup-plugin-natives

Extract native modules (.node files) while creating a rollup bundle and put them in one place
JavaScript
20
star
12

SpreadsheetStreams.net

Streaming interfaces for writing spreadsheets in .NET - supports csv, xml, xlsx.
C#
18
star
13

DGCurvedLabel

A UILabel that curves the text around the specified radius
Objective-C
14
star
14

node-optimize

Optimize a node project to a single JS file for distribution release.
JavaScript
13
star
15

node-vboxmanage

A wrapper for VirtualBox CLI with Promises
JavaScript
12
star
16

DGTeaEncryptor

A lightweight TEA (XXTEA) encryption library for iOS / ObjC.
Objective-C
10
star
17

UITableViewRevealer

A revealer for the UITableView - shows hidden views like timestamps in iMessage app.
Swift
10
star
18

DGDownloadManager

A simple download manager for iOS / ObjC
Objective-C
9
star
19

MailQueueNet

A .NET service that queues .NET's MailMessage objects to go out in the background
C#
8
star
20

jquery.maskedinput

A jQuery masked input control
JavaScript
6
star
21

node-childprocess-queue

Use `childprocess` module freely while limiting the amount of concurrent processes
JavaScript
5
star
22

DGPingUtility

A ping utility for iOS.
Objective-C
5
star
23

DGToneGenerator

A DTMF tone generator for iOS / ObjC
Objective-C
5
star
24

DGImageLoaderView

A bullet-proof high-performance image view that loads from your URLs (web & local!) for iOS / ObjC
Objective-C
5
star
25

DGAudioTranscoder

An audio transcoding module - takes any source format, transcodes to any codec available on iOS/OSX.
Objective-C
5
star
26

DGStateBroadcaster

A broadcaster for several sensors (Low battery, distance travelled, location accuracy, network reachability) for iOS / ObjC
Objective-C
5
star
27

DGFastImageSize

Retrieve image dimensions in no-time at all. High performance image dimension reader for iOS / ObjC.
Objective-C
5
star
28

SequelNet

SQL abstraction/generalization/protection layer.
C#
4
star
29

SwiftEval

Eval for Swift
Swift
4
star
30

DGSpreadSheetExport

CSV or XMLSS (XML Spreadsheet) generation library for iOS / ObjC
Objective-C
4
star
31

js-i18n

An i18n library, with support for plurals, dates, C style format specifiers and more.
JavaScript
4
star
32

node-spreadsheet-writer

A spreadsheet writer, for excel compatible formats. (node.js)
JavaScript
4
star
33

android-httprequest

A chainable HttpRequest/Response library for Android.
Java
4
star
34

DGSlideViewController

A sliding view controller for iOS
Objective-C
4
star
35

DGDropdownView

A customizable "drop view" like the iOS Push Notification (iOS / ObjC)
Objective-C
4
star
36

DGLocationManager

A singleton Location Manager as a replacement for CLLocationManager (iOS / ObjC)
Objective-C
4
star
37

grunt-node-optimize

A grunt task for node-optimizer. Optimize a node project to a single JS file for distribution release.
JavaScript
3
star
38

DGBarcodeView

Barcode view for iOS / ObjC
Objective-C
3
star
39

DGPhoneNumberFormatter

An NSFormatter for phone numbers. (iOS / ObjC)
Objective-C
3
star
40

virtual-list-helper

JavaScript
3
star
41

node-benchmark

A benchmarking utility for Node.js
JavaScript
3
star
42

DGPopupView

A customizable popup view for iOS / ObjC
Swift
3
star
43

DGButton

A UIButton subclass with support for more customization, including RTLing image position (iOS / ObjC)
Objective-C
3
star
44

DGFocusImageGallery

An image gallery view controller for iOS / ObjC
Objective-C
3
star
45

Codenet

A collection of .NET components in several subjects
C#
3
star
46

DGBlockThrottle

A little utility to throttle calls to a block in ObjC
Objective-C
3
star
47

Eval.net

Evaluate basic expressions (math,constants,logic,functions) in .NET runtime
C#
3
star
48

DGPageControl

A customizable paging control, compatible alternative to UIPageControl (iOS / ObjC)
Objective-C
2
star
49

Imaging.net

A helper library for imaging stuff!
C#
2
star
50

sitback

A git diff based approach to package and deploy server apps of any kind.
JavaScript
2
star
51

KotlinEval

Kotlin port of the BigEval library
Kotlin
2
star
52

DGGrayScaleImage

A UIImage that represents a grayscale version of another UIImage. (iOS / ObjC)
Objective-C
2
star
53

jquery.dropzone

A simple jQuery plugin for creating styleable dropzones for files
JavaScript
2
star
54

DGLabelNumberAnimator

A helper library that will animate labels between two numbers (iOS / ObjC)
Objective-C
2
star
55

DGiTunesSearchApi

A wrapper for iTunes' search API, for iOS / ObjC.
Objective-C
2
star
56

DGFlatProgressBarView

A flat progress bar view, as an alternative to UIProgressView.
Objective-C
2
star
57

jquery.numeric

Restrict input fields to numeric input, and a generic jQuery `valueAsNumber`
JavaScript
2
star
58

dg.Utilities

A collection of utilities in all kinds of areas
C#
2
star
59

jquery.fakebutton

Make an element respond like a button - to keyboard, mouse and touch events.
JavaScript
2
star
60

node-memory-lock

A memory-based read-write lock for Node.js
JavaScript
2
star
61

NSString-Trims

An extension to NSString to easily trim whitespace. (iOS / ObjC)
Objective-C
2
star
62

selectbox

JavaScript
2
star
63

node-netmsg

Simple message transfer over network between Node.js, with Buffer and file support
JavaScript
2
star
64

DGTintableImageView

A UIView that presents a UIImage with a tint to another color. (iOS / ObjC)
Objective-C
2
star
65

jquery.fastdom

Make all interactive elements on the page respond correctly to touch events.
JavaScript
2
star
66

node-vmrun

A wrapper for VMWare CLI with Promises
JavaScript
2
star
67

DGTextFieldPickerView

A UITextField that can show a UIPickerView or UIDatePicker for options (iOS / ObjC)
Objective-C
2
star
68

DGKeyboardScrollHandler

A helper to handle scrolling your UITableView or UIScrollView when the keyboard appears (iOS / ObjC)
Swift
2
star
69

FileDir

A cross-platform file and directory enumerator. With UTF8 (linux) and Wide Char (windows) support.
C++
2
star
70

NSUserDefaults-DefaultValues

An extension to NSUserDefaults to retrieve values with an optional default value. (iOS / ObjC)
Objective-C
2
star
71

DGInputAccessoryToolbar

A standard "prev/next/done" toolbar to put as inputAccessoryView for your keyboard (iOS / ObjC)
Objective-C
2
star
72

DGTextField

A customizable UITextField subclass (iOS / ObjC)
Objective-C
1
star
73

DGPickerButton

A UIButton that can show a UIPickerView or UIDatePicker for options. (iOS / ObjC)
Objective-C
1
star
74

DGTwoSidedView

A UIView subclass that has two sides, so you can flip it or move in 3d space (iOS / ObjC)
Objective-C
1
star
75

node-git-attributes

Parse gitattributes files
JavaScript
1
star
76

grooveshark-objc-sdk

Grooveshark SDK for iOS with ObjC
Objective-C
1
star
77

node-cli-parser

A different kind (non-unix) of a CLI arguments parser.
JavaScript
1
star
78

NSString-EmailValidation

An extension to NSString to for email address validation. (iOS / ObjC)
Objective-C
1
star
79

node-bson-json-transform

A Node.js Transform for streaming Bson into Json
JavaScript
1
star
80

DGBorderedLabel

An alternative to UILabel, with the option of a bordered text. (iOS / ObjC)
Objective-C
1
star
81

jquery.mobileselectmenu

Converts a menu to a select HTML. Good for responsive designs.
JavaScript
1
star
82

zone-polyfill

A Zone polyfill for node.js
JavaScript
1
star
83

node-win32filetime

Convert from Win32 FILETIME struct to UNIX/JS time, and vice-versa
JavaScript
1
star
84

DGGeocoding

A geocoding services API wrapper, for iOS / ObjC
Objective-C
1
star
85

jquery.fixedbar

Keep a bar or other component fixed while scrolling the window beyond a certain point
JavaScript
1
star
86

NSString-Javascript

An extension to NSString to simply encode strings for JavaScript. (iOS / ObjC)
Objective-C
1
star
87

DGNumberBadgeView

A number badge view, similar to iOS' push notification badge (iOS / ObjC)
Objective-C
1
star
88

jquery.with-hovers

Detect if the platform should have CSS hovers. Touch screens without mouse support should not have hovers!
JavaScript
1
star
89

DGCompatibleSegmentedControl

A subclass of UISegmentControl that will render on iOS 6.0 like it's iOS 7.0
Objective-C
1
star