https://github.com/PhilJay/MPAndroidChart-Realm
http://realm.io related features of the MPAndroidChart library.
https://github.com/PhilJay/MPAndroidChart-Realm
Last synced: 7 months ago
JSON representation
http://realm.io related features of the MPAndroidChart library.
- Host: GitHub
- URL: https://github.com/PhilJay/MPAndroidChart-Realm
- Owner: PhilJay
- License: apache-2.0
- Created: 2016-06-09T11:04:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-30T08:27:30.000Z (over 7 years ago)
- Last Synced: 2024-08-05T19:35:24.874Z (10 months ago)
- Language: Java
- Homepage:
- Size: 2.06 MB
- Stars: 197
- Watchers: 11
- Forks: 37
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://twitter.com/philippjahoda)
[](http://twitter.com/mpandroidchart)
[](https://android-arsenal.com/details/1/3838)
[](https://jitpack.io/#PhilJay/MPAndroidChart-Realm) [](https://android-arsenal.com/api?level=16)
This repository contains all [Realm.io](http://realm.io) related features of the [MPAndroidChart](https://github.com/PhilJay/MPAndroidChart) library based on **Realm v4.2.0** release.
# Getting Started
- To use this library, add the following to your project level `build.gradle`:
```gradle
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
```
- Add this to your app `build.gradle`:
```gradle
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart-Realm:v3.0.3@aar'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
}
```The MPAndroidChart-Realm dependency **does not include** the latest MPAndroidChart release, so you have to add the dependency to [MPAndroidChart](https://github.com/PhilJay/MPAndroidChart#usage) as well (as shown above). You also have to add the [Realm.io dependency](https://realm.io/docs/java/latest/#getting-started).
# Sample
Using [MPAndroidChart](https://github.com/PhilJay/MPAndroidChart) with [Realm.io](https://realm.io) is easier than you think.
```java
// get realm instance
Realm realm = Realm.getDefaultInstance();// load your data from Realm.io database
RealmResults results = realm.where(YourData.class).findAll();// create a DataSet and specify fields, MPAndroidChart-Realm does the rest
RealmBarDataSet dataSet = new RealmBarDataSet(results, "xValue", "yValue");// create a data object with the dataset
BarData data = new BarData(dataSet);
chart.setData(data);
chart.invalidate(); // refresh
```# Tutorial
[Here](https://github.com/PhilJay/MPAndroidChart-Realm/wiki/Realm.io-database-integration), you can find a full guide on how to plot data from Realm.io database with MPAndroidChart from scratch.