No Description

Jacob Christie e065048c7e CHRTCombinedChartView 4 years ago
.github 847e8225a5 Added FUNDING.yml 5 years ago
Assets bf3080f470 reformat README (+2 squashed commits) 5 years ago
Charts-Objc e065048c7e CHRTCombinedChartView 4 years ago
Charts.xcodeproj b03db8acc6 Added Indexed from SwiftAlgorithms 4 years ago
Charts.xcworkspace 2b98bfa6ca CHRTBarChartView 4 years ago
ChartsDemo-iOS e065048c7e CHRTCombinedChartView 4 years ago
ChartsDemo-macOS 84b501f311 Merge branch '4.0.0' into ResolveConflict 5 years ago
Source e065048c7e CHRTCombinedChartView 4 years ago
Tests 9d73463c15 recreate iOS+tvOS images due to iOS14 SDK uncertain changes. 4 years ago
scripts f6525a0443 update xcode project for xcode 9 8 years ago
.gitignore 7d1296d102 Fix gitignore to ignore .swiftpm as a directory 6 years ago
.travis.yml 60bfc33919 fix Carthage error after changing to source compile. https://github.com/Carthage/Carthage/issues/3019 4 years ago
CHANGELOG.md 7ac4a05e83 1. update gem file. Using ruby-2.4.0 as minimum version for bundle update, as github_changelog_generator cannot be run on ruby-2.7.0(https://github.com/github-changelog-generator/github-changelog-generator/issues/800), and ruby <2.4 will have openssl failures due to brew removed openssl@1.0 recently, this broke my Catalina machine. 5 years ago
CONTRIBUTING.md 21079ab164 Update CONTRIBUTING.md 9 years ago
Cartfile.private b155c2f64d Minor updates for Swift 5 (#3874) 6 years ago
Cartfile.resolved 58ab2e01b7 revert back to convenience init for BarChartDataSet 5 years ago
Charts.podspec 3f84f8777e fix all compile errors and wrong symbols either by git or me. 5 years ago
Gemfile 25c0742771 fix pod build and update gems 5 years ago
Gemfile.lock 7ac4a05e83 1. update gem file. Using ruby-2.4.0 as minimum version for bundle update, as github_changelog_generator cannot be run on ruby-2.7.0(https://github.com/github-changelog-generator/github-changelog-generator/issues/800), and ruby <2.4 will have openssl failures due to brew removed openssl@1.0 recently, this broke my Catalina machine. 5 years ago
Indexed.swift b03db8acc6 Added Indexed from SwiftAlgorithms 4 years ago
LICENSE acb436a1b7 Update License 6 years ago
Package.swift 1086579ea1 Unspecify library type 6 years ago
README.md 3f84f8777e fix all compile errors and wrong symbols either by git or me. 5 years ago
Rakefile 2752c6c859 bump to iPhone 8 as iPhone 7 has been dropped out 5 years ago
carthage.sh 60bfc33919 fix Carthage error after changing to source compile. https://github.com/Carthage/Carthage/issues/3019 4 years ago

README.md

Version 4.0.0, synced to MPAndroidChart #f6a398b

alt tag Supported Platforms Releases Latest pod release Carthage compatible Build Status codecov

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 11 / Swift 5 (master branch)
  • iOS >= 8.0 (Use as an Embedded Framework)
  • tvOS >= 9.0
  • macOS >= 10.11

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 Charts.xcodeproj to your project
  2. Go to your target's settings, hit the "+" under the "Embedded Binaries" section, and select the Charts.framework
  3. @import Charts
  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 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

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 'Charts' to your Podfile. "Charts" 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

Charts now include Carthage prebuilt binaries.

github "danielgindi/Charts" == 4.0.0
github "danielgindi/Charts" ~> 4.0.0

In order to build the binaries for a new release, use carthage build --no-skip-current && carthage archive Charts.

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
  • Study the (Still incomplete Doc-Percent) Pod-Documentation
  • 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) 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.