More Cleanup
I've removed the realm examples, mainly because the library was buggy. In the previous commit, I already removed the examples from the list since they didn't add anything to the overall demonstration. I thought that if anyone wants to use realm.io with the charts, they can see the actual library. The file structure has been updated to match how Android Studio does things. Some files added way back when have been deleted as they don't do anything but cause the linter to freak out about 'unused properties' All 'build.gradle' files have been refreshed as well. Small addition to the README file to add a quick way to reach sections of the page.
This commit is contained in:
parent
db7dda2b7e
commit
5030b36c86
173 changed files with 71 additions and 1576 deletions
|
@ -1,4 +0,0 @@
|
|||
#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
|
||||
#Mon Jan 18 23:02:46 CET 2016
|
||||
build.family.org.gradle.tooling.model.eclipse.HierarchicalEclipseProject=;MPChartExample;MPChartLib;
|
||||
org.springsource.ide.eclipse.gradle.rootprojectloc=
|
|
@ -1,3 +0,0 @@
|
|||
#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
|
||||
#Mon Jan 18 23:02:46 CET 2016
|
||||
org.springsource.ide.eclipse.gradle.rootprojectloc=..
|
|
@ -1,5 +1,4 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'realm-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
|
@ -10,15 +9,6 @@ android {
|
|||
versionCode 56
|
||||
versionName '3.0.3'
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs = ['src']
|
||||
res.srcDirs = ['res']
|
||||
assets.srcDirs = ['assets']
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
@ -27,25 +17,10 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "androidx.appcompat:appcompat:1.0.0"
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
//implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
//implementation "androidx.legacy:legacy-support-v13:1.0.0"
|
||||
//compile project(':MPChartLib-Realm') // clone "https://github.com/PhilJay/MPAndroidChart-Realm" to get this or uncomment the gradle dependency below:
|
||||
implementation 'com.github.PhilJay:MPAndroidChart-Realm:v2.0.2@aar'
|
||||
implementation project(':MPChartLib')
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { // this is for realm-db
|
||||
url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
21
MPChartExample/proguard-rules.pro
vendored
Normal file
21
MPChartExample/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -1,15 +0,0 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-23
|
||||
android.library.reference.1=../MPChartLib
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.github.mikephil.charting.charts.BubbleChart
|
||||
android:id="@+id/chart1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.github.mikephil.charting.charts.CandleStickChart
|
||||
android:id="@+id/chart1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.github.mikephil.charting.charts.HorizontalBarChart
|
||||
android:id="@+id/chart1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.github.mikephil.charting.charts.PieChart
|
||||
android:id="@+id/chart1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
android:id="@+id/lineChart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.github.mikephil.charting.charts.BarChart
|
||||
android:id="@+id/barChart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.github.mikephil.charting.charts.ScatterChart
|
||||
android:id="@+id/chart1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/viewGithub"
|
||||
android:title="@string/viewGithub">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/viewRealm"
|
||||
android:title="@string/realmIOWebsite">
|
||||
</item>
|
||||
|
||||
</menu>
|
|
@ -1,173 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.custom;
|
||||
|
||||
|
||||
import io.realm.RealmList;
|
||||
import io.realm.RealmObject;
|
||||
|
||||
/**
|
||||
* Demo class that encapsulates data stored in realm.io database.
|
||||
* This class represents data suitable for all chart-types.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class RealmDemoData extends RealmObject {
|
||||
|
||||
private float yValue;
|
||||
private float xValue;
|
||||
|
||||
private float open, close, high, low;
|
||||
|
||||
private float bubbleSize;
|
||||
|
||||
private RealmList<RealmFloat> stackValues;
|
||||
|
||||
private String someStringField;
|
||||
|
||||
/**
|
||||
* label for pie entries
|
||||
*/
|
||||
private String label;
|
||||
|
||||
public RealmDemoData() {}
|
||||
|
||||
public RealmDemoData(float xValue, float yValue) {
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for stacked bars.
|
||||
*
|
||||
* @param xValue x position for bars
|
||||
* @param stackValues values of bars in the stack
|
||||
*/
|
||||
public RealmDemoData(float xValue, float[] stackValues) {
|
||||
this.xValue = xValue;
|
||||
this.stackValues = new RealmList<>();
|
||||
|
||||
for (float val : stackValues) {
|
||||
this.stackValues.add(new RealmFloat(val));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for candles.
|
||||
*
|
||||
* @param xValue x position of candle
|
||||
* @param high high value for candle
|
||||
* @param low low value for candle
|
||||
* @param open open value for candle
|
||||
* @param close close value for candle
|
||||
*/
|
||||
public RealmDemoData(float xValue, float high, float low, float open, float close) {
|
||||
this.yValue = (high + low) / 2f;
|
||||
this.high = high;
|
||||
this.low = low;
|
||||
this.open = open;
|
||||
this.close = close;
|
||||
this.xValue = xValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for bubbles.
|
||||
*
|
||||
* @param xValue x position of bubble
|
||||
* @param yValue y position of bubble
|
||||
* @param bubbleSize size of bubble
|
||||
*/
|
||||
public RealmDemoData(float xValue, float yValue, float bubbleSize) {
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
this.bubbleSize = bubbleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for pie chart.
|
||||
*
|
||||
* @param yValue size of pie slice
|
||||
* @param label label for pie slice
|
||||
*/
|
||||
public RealmDemoData(float yValue, String label) {
|
||||
this.yValue = yValue;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public float getYValue() {
|
||||
return yValue;
|
||||
}
|
||||
|
||||
public void setYValue(float yValue) {
|
||||
this.yValue = yValue;
|
||||
}
|
||||
|
||||
public float getXValue() {
|
||||
return xValue;
|
||||
}
|
||||
|
||||
public void setXValue(float xValue) {
|
||||
this.xValue = xValue;
|
||||
}
|
||||
|
||||
public RealmList<RealmFloat> getStackValues() {
|
||||
return stackValues;
|
||||
}
|
||||
|
||||
public void setStackValues(RealmList<RealmFloat> stackValues) {
|
||||
this.stackValues = stackValues;
|
||||
}
|
||||
|
||||
public float getOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(float open) {
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public float getClose() {
|
||||
return close;
|
||||
}
|
||||
|
||||
public void setClose(float close) {
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
public float getHigh() {
|
||||
return high;
|
||||
}
|
||||
|
||||
public void setHigh(float high) {
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
public float getLow() {
|
||||
return low;
|
||||
}
|
||||
|
||||
public void setLow(float low) {
|
||||
this.low = low;
|
||||
}
|
||||
|
||||
public float getBubbleSize() {
|
||||
return bubbleSize;
|
||||
}
|
||||
|
||||
public void setBubbleSize(float bubbleSize) {
|
||||
this.bubbleSize = bubbleSize;
|
||||
}
|
||||
|
||||
public String getSomeStringField() {
|
||||
return someStringField;
|
||||
}
|
||||
|
||||
public void setSomeStringField(String someStringField) {
|
||||
this.someStringField = someStringField;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.custom;
|
||||
|
||||
import io.realm.RealmObject;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 09/11/15.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class RealmFloat extends RealmObject {
|
||||
|
||||
private float floatValue;
|
||||
|
||||
public RealmFloat() {
|
||||
|
||||
}
|
||||
|
||||
public RealmFloat(float floatValue) {
|
||||
this.floatValue = floatValue;
|
||||
}
|
||||
|
||||
public float getFloatValue() {
|
||||
return floatValue;
|
||||
}
|
||||
|
||||
public void setFloatValue(float value) {
|
||||
this.floatValue = value;
|
||||
}
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarLineChartBase;
|
||||
import com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.ChartData;
|
||||
import com.github.mikephil.charting.formatter.PercentFormatter;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import io.realm.Realm;
|
||||
import io.realm.RealmConfiguration;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 05/11/15.
|
||||
*/
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public abstract class RealmBaseActivity extends DemoBase {
|
||||
|
||||
protected Realm mRealm;
|
||||
|
||||
protected Typeface mTf;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTitle("Realm.io Examples");
|
||||
}
|
||||
|
||||
protected void setup(Chart<?> chart) {
|
||||
|
||||
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
|
||||
// no description text
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// enable touch gestures
|
||||
chart.setTouchEnabled(true);
|
||||
|
||||
if (chart instanceof BarLineChartBase) {
|
||||
|
||||
BarLineChartBase mChart = (BarLineChartBase) chart;
|
||||
|
||||
mChart.setDrawGridBackground(false);
|
||||
|
||||
// enable scaling and dragging
|
||||
mChart.setDragEnabled(true);
|
||||
mChart.setScaleEnabled(true);
|
||||
|
||||
// if disabled, scaling can be done on x- and y-axis separately
|
||||
mChart.setPinchZoom(false);
|
||||
|
||||
YAxis leftAxis = mChart.getAxisLeft();
|
||||
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
|
||||
leftAxis.setTypeface(mTf);
|
||||
leftAxis.setTextSize(8f);
|
||||
leftAxis.setTextColor(Color.DKGRAY);
|
||||
leftAxis.setValueFormatter(new PercentFormatter());
|
||||
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setTypeface(mTf);
|
||||
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||
xAxis.setTextSize(8f);
|
||||
xAxis.setTextColor(Color.DKGRAY);
|
||||
|
||||
mChart.getAxisRight().setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void styleData(ChartData data) {
|
||||
data.setValueTypeface(mTf);
|
||||
data.setValueTextSize(8f);
|
||||
data.setValueTextColor(Color.DKGRAY);
|
||||
data.setValueFormatter(new PercentFormatter());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
|
||||
RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
|
||||
Realm.setDefaultConfiguration(realmConfig);
|
||||
|
||||
mRealm = Realm.getDefaultInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mRealm.close();
|
||||
}
|
||||
|
||||
protected void writeToDB(int objectCount) {
|
||||
|
||||
mRealm.beginTransaction();
|
||||
|
||||
mRealm.delete(RealmDemoData.class);
|
||||
|
||||
for (int i = 0; i < objectCount; i++) {
|
||||
|
||||
float value = 40f + (float) (Math.random() * 60f);
|
||||
|
||||
RealmDemoData d = new RealmDemoData(i, value);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
mRealm.commitTransaction();
|
||||
}
|
||||
|
||||
protected void writeToDBStack(int objectCount) {
|
||||
|
||||
mRealm.beginTransaction();
|
||||
|
||||
mRealm.delete(RealmDemoData.class);
|
||||
|
||||
for (int i = 0; i < objectCount; i++) {
|
||||
|
||||
float val1 = 34f + (float) (Math.random() * 12.0f);
|
||||
float val2 = 34f + (float) (Math.random() * 12.0f);
|
||||
float[] stack = new float[]{val1, val2, 100 - val1 - val2};
|
||||
|
||||
RealmDemoData d = new RealmDemoData(i, stack);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
mRealm.commitTransaction();
|
||||
}
|
||||
|
||||
protected void writeToDBCandle(int objectCount) {
|
||||
|
||||
mRealm.beginTransaction();
|
||||
|
||||
mRealm.delete(RealmDemoData.class);
|
||||
|
||||
for (int i = 0; i < objectCount; i++) {
|
||||
|
||||
float val = (float) (Math.random() * 40) + 50f;
|
||||
|
||||
float high = (float) (Math.random() * 9) + 8f;
|
||||
float low = (float) (Math.random() * 9) + 8f;
|
||||
|
||||
float open = (float) (Math.random() * 6) + 1f;
|
||||
float close = (float) (Math.random() * 6) + 1f;
|
||||
|
||||
boolean even = i % 2 == 0;
|
||||
|
||||
RealmDemoData d = new RealmDemoData(i, val + high, val - low, even ? val + open : val - open,
|
||||
even ? val - close : val + close);
|
||||
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
mRealm.commitTransaction();
|
||||
}
|
||||
|
||||
protected void writeToDBBubble(int objectCount) {
|
||||
|
||||
mRealm.beginTransaction();
|
||||
|
||||
mRealm.delete(RealmDemoData.class);
|
||||
|
||||
for (int i = 0; i < objectCount; i++) {
|
||||
|
||||
float value = 30f + (float) (Math.random() * 100.0);
|
||||
float size = 15f + (float) (Math.random() * 20.0);
|
||||
|
||||
RealmDemoData d = new RealmDemoData(i, value, size);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
mRealm.commitTransaction();
|
||||
}
|
||||
|
||||
protected void writeToDBPie() {
|
||||
|
||||
mRealm.beginTransaction();
|
||||
|
||||
mRealm.delete(RealmDemoData.class);
|
||||
|
||||
float value1 = 15f + (float) (Math.random() * 8f);
|
||||
float value2 = 15f + (float) (Math.random() * 8f);
|
||||
float value3 = 15f + (float) (Math.random() * 8f);
|
||||
float value4 = 15f + (float) (Math.random() * 8f);
|
||||
float value5 = 100f - value1 - value2 - value3 - value4;
|
||||
|
||||
float[] values = new float[]{value1, value2, value3, value4, value5};
|
||||
String[] labels = new String[]{"iOS", "Android", "WP 10", "BlackBerry", "Other"};
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
RealmDemoData d = new RealmDemoData(values[i], labels[i]);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
mRealm.commitTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToGallery() { /* Intentionally left empty */ }
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityBar extends RealmBaseActivity {
|
||||
|
||||
private BarChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_barchart_noseekbar);
|
||||
|
||||
mChart = findViewById(R.id.chart1);
|
||||
setup(mChart);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDB(20);
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<>(result, "stackValues", "xIndex"); // normal entries
|
||||
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<>(result, "xValue", "yValue"); // stacked entries
|
||||
set.setColors(ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4"));
|
||||
set.setLabel("Realm BarDataSet");
|
||||
|
||||
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
BarData data = new BarData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.setFitBars(true);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.BubbleChart;
|
||||
import com.github.mikephil.charting.data.BubbleData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityBubble extends RealmBaseActivity {
|
||||
|
||||
private BubbleChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_bubblechart_noseekbar);
|
||||
|
||||
mChart = findViewById(R.id.chart1);
|
||||
setup(mChart);
|
||||
|
||||
mChart.getXAxis().setDrawGridLines(false);
|
||||
mChart.getAxisLeft().setDrawGridLines(false);
|
||||
mChart.setPinchZoom(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDBBubble(10);
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
RealmBubbleDataSet<RealmDemoData> set = new RealmBubbleDataSet<>(result, "xValue", "yValue", "bubbleSize");
|
||||
set.setLabel("Realm BubbleDataSet");
|
||||
set.setColors(ColorTemplate.COLORFUL_COLORS, 110);
|
||||
|
||||
ArrayList<IBubbleDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
BubbleData data = new BubbleData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.CandleStickChart;
|
||||
import com.github.mikephil.charting.data.CandleData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityCandle extends RealmBaseActivity {
|
||||
|
||||
private CandleStickChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_candlechart_noseekbar);
|
||||
|
||||
mChart = findViewById(R.id.chart1);
|
||||
setup(mChart);
|
||||
|
||||
mChart.getAxisLeft().setDrawGridLines(false);
|
||||
mChart.getXAxis().setDrawGridLines(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDBCandle(50);
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<>(result, "xValue", "high", "low", "open", "close");
|
||||
set.setLabel("Realm CandleDataSet");
|
||||
set.setShadowColor(Color.DKGRAY);
|
||||
set.setShadowWidth(0.7f);
|
||||
set.setDecreasingColor(Color.RED);
|
||||
set.setDecreasingPaintStyle(Paint.Style.FILL);
|
||||
set.setIncreasingColor(Color.rgb(122, 242, 84));
|
||||
set.setIncreasingPaintStyle(Paint.Style.STROKE);
|
||||
set.setNeutralColor(Color.BLUE);
|
||||
|
||||
ArrayList<ICandleDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
CandleData data = new CandleData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.HorizontalBarChart;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityHorizontalBar extends RealmBaseActivity {
|
||||
|
||||
private HorizontalBarChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_horizontalbarchart_noseekbar);
|
||||
|
||||
mChart = findViewById(R.id.chart1);
|
||||
setup(mChart);
|
||||
|
||||
mChart.getAxisLeft().setAxisMinimum(0f);
|
||||
mChart.setDrawValueAboveBar(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDBStack(50);
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<>(result, "stackValues", "xIndex"); // normal entries
|
||||
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<>(result, "xValue", "stackValues", "floatValue"); // stacked entries
|
||||
set.setColors(ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E"));
|
||||
set.setLabel("Mobile OS distribution");
|
||||
set.setStackLabels(new String[]{"iOS", "Android", "Other"});
|
||||
|
||||
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
BarData data = new BarData(dataSets);
|
||||
styleData(data);
|
||||
data.setValueTextColor(Color.WHITE);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityLine extends RealmBaseActivity {
|
||||
|
||||
private LineChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart_noseekbar);
|
||||
|
||||
mChart = findViewById(R.id.chart1);
|
||||
setup(mChart);
|
||||
|
||||
mChart.getAxisLeft().setAxisMaximum(150f);
|
||||
mChart.getAxisLeft().setAxisMinimum(0f);
|
||||
mChart.getAxisLeft().setDrawGridLines(false);
|
||||
mChart.getXAxis().setDrawGridLines(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDB(40);
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<>(result, "xValue", "yValue");
|
||||
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||
set.setLabel("Realm LineDataSet");
|
||||
set.setDrawCircleHole(false);
|
||||
set.setColor(ColorTemplate.rgb("#FF5722"));
|
||||
set.setCircleColor(ColorTemplate.rgb("#FF5722"));
|
||||
set.setLineWidth(1.8f);
|
||||
set.setCircleRadius(3.6f);
|
||||
|
||||
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
LineData data = new LineData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityPie extends RealmBaseActivity {
|
||||
|
||||
private PieChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_piechart_noseekbar);
|
||||
|
||||
mChart = findViewById(R.id.chart1);
|
||||
setup(mChart);
|
||||
|
||||
mChart.setCenterText(generateCenterSpannableText());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDBPie();
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<>(result, "yValue", "label");
|
||||
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
set.setLabel("Example market share");
|
||||
set.setSliceSpace(2);
|
||||
|
||||
// create a data object with the dataset list
|
||||
PieData data = new PieData(set);
|
||||
styleData(data);
|
||||
data.setValueTextColor(Color.WHITE);
|
||||
data.setValueTextSize(12f);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400);
|
||||
}
|
||||
|
||||
private SpannableString generateCenterSpannableText() {
|
||||
|
||||
SpannableString s = new SpannableString("Realm.io\nmobile database");
|
||||
s.setSpan(new ForegroundColorSpan(Color.rgb(240, 115, 126)), 0, 8, 0);
|
||||
s.setSpan(new RelativeSizeSpan(2.2f), 0, 8, 0);
|
||||
s.setSpan(new StyleSpan(Typeface.ITALIC), 9, s.length(), 0);
|
||||
s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 9, s.length(), 0);
|
||||
s.setSpan(new RelativeSizeSpan(0.85f), 9, s.length(), 0);
|
||||
return s;
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.RadarChart;
|
||||
import com.github.mikephil.charting.data.RadarData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmRadarDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IRadarDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityRadar extends RealmBaseActivity {
|
||||
|
||||
private RadarChart chart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_radarchart);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
setup(chart);
|
||||
|
||||
chart.getYAxis().setEnabled(false);
|
||||
chart.getXAxis().setEnabled(false);
|
||||
chart.setWebAlpha(180);
|
||||
chart.setWebColorInner(Color.DKGRAY);
|
||||
chart.setWebColor(Color.GRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDB(7);
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<>(result, "stackValues", "xIndex"); // normal entries
|
||||
RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<>(result, "yValue"); // stacked entries
|
||||
set.setLabel("Realm RadarDataSet");
|
||||
set.setDrawFilled(true);
|
||||
set.setColor(ColorTemplate.rgb("#009688"));
|
||||
set.setFillColor(ColorTemplate.rgb("#009688"));
|
||||
set.setFillAlpha(130);
|
||||
set.setLineWidth(2f);
|
||||
|
||||
ArrayList<IRadarDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
RadarData data = new RadarData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
chart.setData(data);
|
||||
chart.animateY(1400);
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.ScatterChart;
|
||||
import com.github.mikephil.charting.data.ScatterData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 21/10/15.
|
||||
*/
|
||||
public class RealmDatabaseActivityScatter extends RealmBaseActivity {
|
||||
|
||||
private ScatterChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_scatterchart_noseekbar);
|
||||
|
||||
mChart = findViewById(R.id.chart1);
|
||||
setup(mChart);
|
||||
|
||||
mChart.getAxisLeft().setDrawGridLines(false);
|
||||
mChart.getXAxis().setDrawGridLines(false);
|
||||
mChart.setPinchZoom(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
writeToDB(45);
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
|
||||
|
||||
RealmScatterDataSet<RealmDemoData> set = new RealmScatterDataSet<>(result, "xValue", "yValue");
|
||||
set.setLabel("Realm ScatterDataSet");
|
||||
set.setScatterShapeSize(9f);
|
||||
set.setColor(ColorTemplate.rgb("#CDDC39"));
|
||||
set.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
|
||||
|
||||
ArrayList<IScatterDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
ScatterData data = new ScatterData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
mChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.ContentItem;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.MyAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.Realm;
|
||||
import io.realm.RealmConfiguration;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 07/12/15.
|
||||
*/
|
||||
public class RealmMainActivity extends Activity implements AdapterView.OnItemClickListener {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
setTitle("Realm.io Examples");
|
||||
|
||||
ArrayList<ContentItem> objects = new ArrayList<>();
|
||||
|
||||
objects.add(new ContentItem("Line Chart", "Creating a LineChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Bar Chart",
|
||||
"Creating a BarChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Horizontal Bar Chart",
|
||||
"Creating a HorizontalBarChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Scatter Chart",
|
||||
"Creating a ScatterChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Candle Stick Chart", "Creating a CandleStickChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Bubble Chart", "Creating a BubbleChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Pie Chart", "Creating a PieChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Radar Chart", "Creating a RadarChart with Realm.io database"));
|
||||
objects.add(new ContentItem("Realm Wiki", "This is the code related to the wiki entry about realm.io on the MPAndroidChart github page."));
|
||||
|
||||
MyAdapter adapter = new MyAdapter(this, objects);
|
||||
|
||||
ListView lv = findViewById(R.id.listView1);
|
||||
lv.setAdapter(adapter);
|
||||
|
||||
lv.setOnItemClickListener(this);
|
||||
|
||||
Realm.init(this);
|
||||
|
||||
// Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
|
||||
RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
|
||||
Realm.setDefaultConfiguration(realmConfig);
|
||||
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.deleteAll();
|
||||
realm.commitTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> av, View v, int pos, long arg3) {
|
||||
|
||||
Intent i;
|
||||
|
||||
switch (pos) {
|
||||
case 0:
|
||||
i = new Intent(this, RealmDatabaseActivityLine.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 1:
|
||||
i = new Intent(this, RealmDatabaseActivityBar.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 2:
|
||||
i = new Intent(this, RealmDatabaseActivityHorizontalBar.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 3:
|
||||
i = new Intent(this, RealmDatabaseActivityScatter.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 4:
|
||||
i = new Intent(this, RealmDatabaseActivityCandle.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 5:
|
||||
i = new Intent(this, RealmDatabaseActivityBubble.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 6:
|
||||
i = new Intent(this, RealmDatabaseActivityPie.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 7:
|
||||
i = new Intent(this, RealmDatabaseActivityRadar.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 8:
|
||||
i = new Intent(this, RealmWikiExample.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
|
||||
overridePendingTransition(R.anim.move_right_in_activity, R.anim.move_left_out_activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.realm, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://realm.io"));
|
||||
startActivity(i);
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.AxisBase;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet;
|
||||
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.realm.RealmResults;
|
||||
|
||||
/**
|
||||
* Created by Philipp Jahoda on 18/12/15.
|
||||
*/
|
||||
public class RealmWikiExample extends RealmBaseActivity {
|
||||
|
||||
private LineChart lineChart;
|
||||
private BarChart barChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_realm_wiki);
|
||||
|
||||
lineChart = findViewById(R.id.lineChart);
|
||||
barChart = findViewById(R.id.barChart);
|
||||
setup(lineChart);
|
||||
setup(barChart);
|
||||
|
||||
lineChart.setExtraBottomOffset(5f);
|
||||
barChart.setExtraBottomOffset(5f);
|
||||
|
||||
lineChart.getAxisLeft().setDrawGridLines(false);
|
||||
lineChart.getXAxis().setDrawGridLines(false);
|
||||
lineChart.getXAxis().setLabelCount(5);
|
||||
lineChart.getXAxis().setGranularity(1f);
|
||||
barChart.getAxisLeft().setDrawGridLines(false);
|
||||
barChart.getXAxis().setDrawGridLines(false);
|
||||
barChart.getXAxis().setLabelCount(5);
|
||||
barChart.getXAxis().setGranularity(1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume(); // setup realm
|
||||
|
||||
mRealm.beginTransaction();
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
Score score1 = new Score(100f, 0f, "Peter");
|
||||
mRealm.copyToRealm(score1);
|
||||
Score score2 = new Score(110f, 1f, "Lisa");
|
||||
mRealm.copyToRealm(score2);
|
||||
Score score3 = new Score(130f, 2f, "Dennis");
|
||||
mRealm.copyToRealm(score3);
|
||||
Score score4 = new Score(70f, 3f, "Luke");
|
||||
mRealm.copyToRealm(score4);
|
||||
Score score5 = new Score(80f, 4f, "Sarah");
|
||||
mRealm.copyToRealm(score5);
|
||||
|
||||
mRealm.commitTransaction();
|
||||
|
||||
// add data to the chart
|
||||
setData();
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
|
||||
// LINE-CHART
|
||||
final RealmResults<Score> results = mRealm.where(Score.class).findAll();
|
||||
|
||||
|
||||
IAxisValueFormatter formatter = new IAxisValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value, AxisBase axis) {
|
||||
Score result = results.get((int) value);
|
||||
return result != null ? result.playerName : "";
|
||||
}
|
||||
};
|
||||
|
||||
lineChart.getXAxis().setValueFormatter(formatter);
|
||||
barChart.getXAxis().setValueFormatter(formatter);
|
||||
|
||||
RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<>(results, "scoreNr", "totalScore");
|
||||
lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||
lineDataSet.setLabel("Result Scores");
|
||||
lineDataSet.setDrawCircleHole(false);
|
||||
lineDataSet.setColor(ColorTemplate.rgb("#FF5722"));
|
||||
lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722"));
|
||||
lineDataSet.setLineWidth(1.8f);
|
||||
lineDataSet.setCircleRadius(3.6f);
|
||||
|
||||
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(lineDataSet);
|
||||
|
||||
LineData lineData = new LineData(dataSets);
|
||||
styleData(lineData);
|
||||
|
||||
// set data
|
||||
lineChart.setData(lineData);
|
||||
lineChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
|
||||
|
||||
// BAR-CHART
|
||||
RealmBarDataSet<Score> barDataSet = new RealmBarDataSet<>(results, "scoreNr", "totalScore");
|
||||
barDataSet.setColors(ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4"));
|
||||
barDataSet.setLabel("Realm BarDataSet");
|
||||
|
||||
ArrayList<IBarDataSet> barDataSets = new ArrayList<>();
|
||||
barDataSets.add(barDataSet);
|
||||
|
||||
BarData barData = new BarData(barDataSets);
|
||||
styleData(barData);
|
||||
|
||||
barChart.setData(barData);
|
||||
barChart.setFitBars(true);
|
||||
barChart.animateY(1400, Easing.EaseInOutQuart);
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.realm;
|
||||
|
||||
|
||||
import io.realm.RealmObject;
|
||||
|
||||
/**
|
||||
* our data object
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
public class Score extends RealmObject {
|
||||
|
||||
public float totalScore;
|
||||
|
||||
public float scoreNr;
|
||||
|
||||
public String playerName;
|
||||
|
||||
public Score() {}
|
||||
|
||||
public Score(float totalScore, float scoreNr, String playerName) {
|
||||
this.scoreNr = scoreNr;
|
||||
this.playerName = playerName;
|
||||
this.totalScore = totalScore;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,9 +19,9 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="LineChartActivity1" /> <!-- android:configChanges="keyboardHidden|orientation|screenSize" -->
|
||||
<activity android:name="LineChartActivity1" />
|
||||
<activity android:name="LineChartActivity2" />
|
||||
<activity android:name=".LineChartTime" />
|
||||
<activity android:name="LineChartTime" />
|
||||
<activity android:name="BarChartActivity" />
|
||||
<activity android:name="HorizontalBarChartActivity" />
|
||||
<activity android:name="PieChartActivity" />
|
||||
|
@ -31,7 +31,7 @@
|
|||
<activity android:name="DrawChartActivity" />
|
||||
<activity android:name="ScatterChartActivity" />
|
||||
<activity android:name="BubbleChartActivity" />
|
||||
<activity android:name="com.xxmassdeveloper.mpchartexample.fragments.SimpleChartDemo" />
|
||||
<activity android:name=".fragments.SimpleChartDemo" />
|
||||
<activity android:name="ListViewBarChartActivity" />
|
||||
<activity android:name="ListViewMultiChartActivity" />
|
||||
<activity android:name="StackedBarActivity" />
|
||||
|
@ -42,25 +42,15 @@
|
|||
<activity android:name="RadarChartActivity" />
|
||||
<activity android:name="LineChartActivityColored" />
|
||||
<activity android:name="DynamicalAddingActivity" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityLine" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityBar" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityHorizontalBar" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityScatter" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityCandle" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityBubble" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityPie" />
|
||||
<activity android:name=".realm.RealmDatabaseActivityRadar" />
|
||||
<activity android:name=".realm.RealmMainActivity" />
|
||||
<activity android:name="RealtimeLineChartActivity" />
|
||||
<activity android:name="CombinedChartActivity" />
|
||||
<activity android:name="PerformanceLineChart" />
|
||||
<activity android:name="BarChartActivitySinus" />
|
||||
<activity android:name="ScrollViewActivity" />
|
||||
<activity android:name="StackedBarActivityNegative" />
|
||||
<activity android:name=".realm.RealmWikiExample" />
|
||||
<activity android:name=".BarChartPositiveNegative" />
|
||||
<activity android:name=".FilledLineActivity" />
|
||||
<activity android:name=".HalfPieChartActivity" />
|
||||
<activity android:name="BarChartPositiveNegative" />
|
||||
<activity android:name="FilledLineActivity" />
|
||||
<activity android:name="HalfPieChartActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
|
@ -131,7 +131,6 @@ public class BarChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
// setting data
|
||||
seekBarY.setProgress(50);
|
||||
seekBarX.setProgress(12);
|
||||
setData(12, 50);
|
||||
|
||||
// chart.setDrawLegend(false);
|
||||
}
|
|
@ -57,6 +57,7 @@ public class BarChartActivityMultiDataset extends DemoBase implements OnSeekBarC
|
|||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarX.setMax(50);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
|
@ -93,7 +93,6 @@ public class CubicLineChartActivity extends DemoBase implements OnSeekBarChangeL
|
|||
|
||||
seekBarX.setProgress(45);
|
||||
seekBarY.setProgress(100);
|
||||
setData(45, 100);
|
||||
|
||||
chart.getLegend().setEnabled(false);
|
||||
|
|
@ -102,7 +102,6 @@ public class HorizontalBarChartActivity extends DemoBase implements OnSeekBarCha
|
|||
yr.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
// yr.setInverted(true);
|
||||
|
||||
setData(12, 50);
|
||||
chart.setFitBars(true);
|
||||
chart.animateY(2500);
|
||||
|
|
@ -56,9 +56,6 @@ public class InvertedLineChartActivity extends DemoBase implements OnSeekBarChan
|
|||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
|
||||
seekBarX.setProgress(45);
|
||||
seekBarY.setProgress(100);
|
||||
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
|
@ -100,7 +97,8 @@ public class InvertedLineChartActivity extends DemoBase implements OnSeekBarChan
|
|||
rightAxis.setEnabled(false);
|
||||
|
||||
// add data
|
||||
setData(25, 50);
|
||||
seekBarX.setProgress(25);
|
||||
seekBarY.setProgress(50);
|
||||
|
||||
// // restrain the maximum scale-out factor
|
||||
// chart.setScaleMinima(3f, 3f);
|
|
@ -91,7 +91,6 @@ public class LineChartActivity2 extends DemoBase implements OnSeekBarChangeListe
|
|||
// add data
|
||||
seekBarX.setProgress(20);
|
||||
seekBarY.setProgress(30);
|
||||
setData(20, 30);
|
||||
|
||||
chart.animateX(1500);
|
||||
|
|
@ -77,8 +77,6 @@ public class LineChartTime extends DemoBase implements OnSeekBarChangeListener {
|
|||
|
||||
// add data
|
||||
seekBarX.setProgress(100);
|
||||
setData(100, 30);
|
||||
chart.invalidate();
|
||||
|
||||
// get the legend (only possible after setting data)
|
||||
Legend l = chart.getLegend();
|
|
@ -97,7 +97,6 @@ public class PieChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
|
||||
seekBarX.setProgress(4);
|
||||
seekBarY.setProgress(10);
|
||||
setData(4, 100);
|
||||
|
||||
chart.animateY(1400, Easing.EaseInOutQuad);
|
||||
// chart.spin(2000, 0, 360);
|
|
@ -102,7 +102,6 @@ public class PiePolylineChartActivity extends DemoBase implements OnSeekBarChang
|
|||
|
||||
seekBarX.setProgress(4);
|
||||
seekBarY.setProgress(100);
|
||||
setData(4, 100);
|
||||
|
||||
chart.animateY(1400, Easing.EaseInOutQuad);
|
||||
// chart.spin(2000, 0, 360);
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue