Work on making realm example work again
This commit is contained in:
parent
6d39afa028
commit
589bd0cbad
22 changed files with 124 additions and 118 deletions
|
@ -10,7 +10,8 @@ import io.realm.RealmObject;
|
|||
*/
|
||||
public class RealmDemoData extends RealmObject {
|
||||
|
||||
private float value;
|
||||
private float yValue;
|
||||
private float xValue;
|
||||
|
||||
private float open, close, high, low;
|
||||
|
||||
|
@ -18,8 +19,6 @@ public class RealmDemoData extends RealmObject {
|
|||
|
||||
private RealmList<RealmFloat> stackValues;
|
||||
|
||||
private int xIndex;
|
||||
|
||||
private String xAxisLabel;
|
||||
private double xAxisPosition;
|
||||
|
||||
|
@ -31,9 +30,9 @@ public class RealmDemoData extends RealmObject {
|
|||
|
||||
}
|
||||
|
||||
public RealmDemoData(float value, int xIndex, double xAxisPosition, String xAxisLabel) {
|
||||
this.value = value;
|
||||
this.xIndex = xIndex;
|
||||
public RealmDemoData(float xValue, float yValue, double xAxisPosition, String xAxisLabel) {
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
this.xAxisPosition = xAxisPosition;
|
||||
this.xAxisLabel = xAxisLabel;
|
||||
}
|
||||
|
@ -41,13 +40,13 @@ public class RealmDemoData extends RealmObject {
|
|||
/**
|
||||
* Constructor for stacked bars.
|
||||
*
|
||||
* @param xValue
|
||||
* @param stackValues
|
||||
* @param xIndex
|
||||
* @param xAxisPosition
|
||||
* @param xAxisLabel
|
||||
*/
|
||||
public RealmDemoData(float[] stackValues, int xIndex, double xAxisPosition, String xAxisLabel) {
|
||||
this.xIndex = xIndex;
|
||||
public RealmDemoData(float xValue, float[] stackValues, double xAxisPosition, String xAxisLabel) {
|
||||
this.xValue = xValue;
|
||||
this.xAxisPosition = xAxisPosition;
|
||||
this.xAxisLabel = xAxisLabel;
|
||||
this.stackValues = new RealmList<RealmFloat>();
|
||||
|
@ -60,21 +59,22 @@ public class RealmDemoData extends RealmObject {
|
|||
/**
|
||||
* Constructor for candles.
|
||||
*
|
||||
* @param xValue
|
||||
* @param high
|
||||
* @param low
|
||||
* @param open
|
||||
* @param close
|
||||
* @param xIndex
|
||||
* @param xAxisPosition
|
||||
* @param xAxisLabel
|
||||
*/
|
||||
public RealmDemoData(float high, float low, float open, float close, int xIndex, double xAxisPosition, String xAxisLabel) {
|
||||
this.value = (high + low) / 2f;
|
||||
public RealmDemoData(float xValue, float high, float low, float open, float close, double xAxisPosition, String
|
||||
xAxisLabel) {
|
||||
this.yValue = (high + low) / 2f;
|
||||
this.high = high;
|
||||
this.low = low;
|
||||
this.open = open;
|
||||
this.close = close;
|
||||
this.xIndex = xIndex;
|
||||
this.xValue = xValue;
|
||||
this.xAxisPosition = xAxisPosition;
|
||||
this.xAxisLabel = xAxisLabel;
|
||||
}
|
||||
|
@ -82,26 +82,34 @@ public class RealmDemoData extends RealmObject {
|
|||
/**
|
||||
* Constructor for bubbles.
|
||||
*
|
||||
* @param value
|
||||
* @param xIndex
|
||||
* @param xValue
|
||||
* @param yValue
|
||||
* @param bubbleSize
|
||||
* @param xAxisPosition
|
||||
* @param xAxisLabel
|
||||
*/
|
||||
public RealmDemoData(float value, int xIndex, float bubbleSize, double xAxisPosition, String xAxisLabel) {
|
||||
this.value = value;
|
||||
this.xIndex = xIndex;
|
||||
public RealmDemoData(float xValue, float yValue, float bubbleSize, double xAxisPosition, String xAxisLabel) {
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
this.bubbleSize = bubbleSize;
|
||||
this.xAxisPosition = xAxisPosition;
|
||||
this.xAxisLabel = xAxisLabel;
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return value;
|
||||
public float getyValue() {
|
||||
return yValue;
|
||||
}
|
||||
|
||||
public void setValue(float value) {
|
||||
this.value = value;
|
||||
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() {
|
||||
|
@ -112,14 +120,6 @@ public class RealmDemoData extends RealmObject {
|
|||
this.stackValues = stackValues;
|
||||
}
|
||||
|
||||
public int getxIndex() {
|
||||
return xIndex;
|
||||
}
|
||||
|
||||
public void setxIndex(int xIndex) {
|
||||
this.xIndex = xIndex;
|
||||
}
|
||||
|
||||
public float getOpen() {
|
||||
return open;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public abstract class RealmBaseActivity extends DemoBase {
|
|||
|
||||
float value = 40f + (float) (Math.random() * 60f);
|
||||
|
||||
RealmDemoData d = new RealmDemoData(value, i, i, "" + i);
|
||||
RealmDemoData d = new RealmDemoData(i, value, i, "" + i);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public abstract class RealmBaseActivity extends DemoBase {
|
|||
float val2 = 34f + (float) (Math.random() * 12.0f);
|
||||
float[] stack = new float[]{val1, val2, 100 - val1 - val2};
|
||||
|
||||
RealmDemoData d = new RealmDemoData(stack, i, i, "" + i);
|
||||
RealmDemoData d = new RealmDemoData(i, stack, i, "" + i);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
|
@ -155,8 +155,8 @@ public abstract class RealmBaseActivity extends DemoBase {
|
|||
|
||||
boolean even = i % 2 == 0;
|
||||
|
||||
RealmDemoData d = new RealmDemoData(val + high, val - low, even ? val + open : val - open,
|
||||
even ? val - close : val + close, i, i, i + "");
|
||||
RealmDemoData d = new RealmDemoData(i, val + high, val - low, even ? val + open : val - open,
|
||||
even ? val - close : val + close, i, i + "");
|
||||
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public abstract class RealmBaseActivity extends DemoBase {
|
|||
float value = 30f + (float) (Math.random() * 100.0);
|
||||
float size = 15f + (float) (Math.random() * 20.0);
|
||||
|
||||
RealmDemoData d = new RealmDemoData(value, i, size, "" + i);
|
||||
RealmDemoData d = new RealmDemoData(i, value, size, "" + i);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ public abstract class RealmBaseActivity extends DemoBase {
|
|||
String[] xValues = new String[]{ "iOS", "Android", "WP 10", "BlackBerry", "Other"};
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
RealmDemoData d = new RealmDemoData(values[i], i, i, xValues[i]);
|
||||
RealmDemoData d = new RealmDemoData(i, values[i], i, xValues[i]);
|
||||
mRealm.copyToRealm(d);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.view.WindowManager;
|
|||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBarData;
|
||||
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;
|
||||
|
@ -50,7 +50,7 @@ public class RealmDatabaseActivityBar extends RealmBaseActivity {
|
|||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
|
||||
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "yValue", "xIndex"); // stacked entries
|
||||
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "yValue", "xValue"); // stacked entries
|
||||
set.setColors(new int[] {ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
|
||||
set.setLabel("Realm BarDataSet");
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class RealmDatabaseActivityBar extends RealmBaseActivity {
|
|||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
RealmBarData data = new RealmBarData(result, "xAxisPosition", "xAxisLabel", dataSets);
|
||||
BarData data = new BarData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.view.WindowManager;
|
|||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.BubbleChart;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBubbleData;
|
||||
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;
|
||||
|
@ -53,7 +53,7 @@ public class RealmDatabaseActivityBubble extends RealmBaseActivity {
|
|||
|
||||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
RealmBubbleDataSet<RealmDemoData> set = new RealmBubbleDataSet<RealmDemoData>(result, "yValue", "xIndex", "bubbleSize");
|
||||
RealmBubbleDataSet<RealmDemoData> set = new RealmBubbleDataSet<RealmDemoData>(result, "xValue", "yValue", "bubbleSize");
|
||||
set.setLabel("Realm BubbleDataSet");
|
||||
set.setColors(ColorTemplate.COLORFUL_COLORS, 110);
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class RealmDatabaseActivityBubble extends RealmBaseActivity {
|
|||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
RealmBubbleData data = new RealmBubbleData(result, "xAxisPosition", "xAxisLabel", dataSets);
|
||||
BubbleData data = new BubbleData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.view.WindowManager;
|
|||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.CandleStickChart;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmCandleData;
|
||||
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;
|
||||
|
@ -53,7 +53,7 @@ public class RealmDatabaseActivityCandle extends RealmBaseActivity {
|
|||
|
||||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "high", "low", "open", "close", "xIndex");
|
||||
RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "xValue", "high", "low", "open", "close");
|
||||
set.setLabel("Realm Realm CandleDataSet");
|
||||
set.setShadowColor(Color.DKGRAY);
|
||||
set.setShadowWidth(0.7f);
|
||||
|
@ -67,7 +67,7 @@ public class RealmDatabaseActivityCandle extends RealmBaseActivity {
|
|||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
RealmCandleData data = new RealmCandleData(result, "xAxisPosition", "xAxisLabel", dataSets);
|
||||
CandleData data = new CandleData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.view.WindowManager;
|
|||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.HorizontalBarChart;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBarData;
|
||||
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;
|
||||
|
@ -54,7 +54,7 @@ public class RealmDatabaseActivityHorizontalBar extends RealmBaseActivity {
|
|||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
|
||||
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex", "floatValue"); // stacked entries
|
||||
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "stackValues", "floatValue"); // stacked entries
|
||||
set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
|
||||
set.setLabel("Mobile OS distribution");
|
||||
set.setStackLabels(new String[]{"iOS", "Android", "Other"});
|
||||
|
@ -63,7 +63,7 @@ public class RealmDatabaseActivityHorizontalBar extends RealmBaseActivity {
|
|||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
RealmBarData data = new RealmBarData(result, "xAxisPosition", "xAxisLabel", dataSets);
|
||||
BarData data = new BarData(dataSets);
|
||||
styleData(data);
|
||||
data.setValueTextColor(Color.WHITE);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.view.WindowManager;
|
|||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmLineData;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
|
@ -54,7 +54,7 @@ public class RealmDatabaseActivityLine extends RealmBaseActivity {
|
|||
|
||||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "yValue", "xIndex");
|
||||
RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue");
|
||||
set.setDrawCubic(false);
|
||||
set.setLabel("Realm LineDataSet");
|
||||
set.setDrawCircleHole(false);
|
||||
|
@ -67,7 +67,7 @@ public class RealmDatabaseActivityLine extends RealmBaseActivity {
|
|||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
RealmLineData data = new RealmLineData(result, "xAxisPosition", "xAxisLabel", dataSets);
|
||||
LineData data = new LineData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
|
|
|
@ -10,7 +10,7 @@ import android.text.style.StyleSpan;
|
|||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmPieData;
|
||||
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;
|
||||
|
@ -54,13 +54,13 @@ public class RealmDatabaseActivityPie extends RealmBaseActivity {
|
|||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
|
||||
RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "yValue", "xIndex"); // stacked entries
|
||||
RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "yValue"); // stacked entries
|
||||
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
set.setLabel("Example market share");
|
||||
set.setSliceSpace(2);
|
||||
|
||||
// create a data object with the dataset list
|
||||
RealmPieData data = new RealmPieData(result, "xAxisPosition", "xAxisLabel", set);
|
||||
PieData data = new PieData(set);
|
||||
styleData(data);
|
||||
data.setValueTextColor(Color.WHITE);
|
||||
data.setValueTextSize(12f);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class RealmDatabaseActivityRadar extends RealmBaseActivity {
|
|||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
|
||||
RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<RealmDemoData>(result, "yValue", "xIndex"); // stacked entries
|
||||
RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<RealmDemoData>(result, "xValue", "yValue"); // stacked entries
|
||||
set.setLabel("Realm RadarDataSet");
|
||||
set.setDrawFilled(true);
|
||||
set.setColor(ColorTemplate.rgb("#009688"));
|
||||
|
|
|
@ -5,6 +5,7 @@ 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.RealmScatterData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
|
||||
|
@ -53,7 +54,7 @@ public class RealmDatabaseActivityScatter extends RealmBaseActivity {
|
|||
|
||||
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);
|
||||
|
||||
RealmScatterDataSet<RealmDemoData> set = new RealmScatterDataSet<RealmDemoData>(result, "yValue", "xIndex");
|
||||
RealmScatterDataSet<RealmDemoData> set = new RealmScatterDataSet<RealmDemoData>(result, "xValue", "yValue");
|
||||
set.setLabel("Realm ScatterDataSet");
|
||||
set.setScatterShapeSize(9f);
|
||||
set.setColor(ColorTemplate.rgb("#CDDC39"));
|
||||
|
@ -63,7 +64,7 @@ public class RealmDatabaseActivityScatter extends RealmBaseActivity {
|
|||
dataSets.add(set); // add the dataset
|
||||
|
||||
// create a data object with the dataset list
|
||||
RealmScatterData data = new RealmScatterData(result, "xAxisPosition", "xAxisLabel", dataSets);
|
||||
ScatterData data = new ScatterData(dataSets);
|
||||
styleData(data);
|
||||
|
||||
// set data
|
||||
|
|
|
@ -6,10 +6,14 @@ 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.realm.implementation.RealmBarData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmLineData;
|
||||
import com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet;
|
||||
import com.github.mikephil.charting.formatter.AxisValueFormatter;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
|
@ -46,6 +50,7 @@ public class RealmWikiExample extends RealmBaseActivity {
|
|||
lineChart.getXAxis().setDrawGridLines(false);
|
||||
barChart.getAxisLeft().setDrawGridLines(false);
|
||||
barChart.getXAxis().setDrawGridLines(false);
|
||||
barChart.getXAxis().setCenterAxisLabels(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,15 +60,15 @@ public class RealmWikiExample extends RealmBaseActivity {
|
|||
mRealm.beginTransaction();
|
||||
|
||||
// write some demo-data into the realm.io database
|
||||
Score score1 = new Score(100f, 0, "Peter");
|
||||
Score score1 = new Score(100f, 0f, "Peter");
|
||||
mRealm.copyToRealm(score1);
|
||||
Score score2 = new Score(110f, 1, "Lisa");
|
||||
Score score2 = new Score(110f, 1f, "Lisa");
|
||||
mRealm.copyToRealm(score2);
|
||||
Score score3 = new Score(130f, 2, "Dennis");
|
||||
Score score3 = new Score(130f, 2f, "Dennis");
|
||||
mRealm.copyToRealm(score3);
|
||||
Score score4 = new Score(70f, 3, "Luke");
|
||||
Score score4 = new Score(70f, 3f, "Luke");
|
||||
mRealm.copyToRealm(score4);
|
||||
Score score5 = new Score(80f, 4, "Sarah");
|
||||
Score score5 = new Score(80f, 4f, "Sarah");
|
||||
mRealm.copyToRealm(score5);
|
||||
|
||||
mRealm.commitTransaction();
|
||||
|
@ -75,11 +80,27 @@ public class RealmWikiExample extends RealmBaseActivity {
|
|||
private void setData() {
|
||||
|
||||
// LINE-CHART
|
||||
RealmResults<Score> results = mRealm.allObjects(Score.class);
|
||||
final RealmResults<Score> results = mRealm.allObjects(Score.class);
|
||||
|
||||
RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<Score>(results, "totalScore", "scoreNr");
|
||||
|
||||
AxisValueFormatter formatter = new AxisValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value, AxisBase axis) {
|
||||
return results.get((int) value).getPlayerName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDecimalDigits() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
lineChart.getXAxis().setValueFormatter(formatter);
|
||||
barChart.getXAxis().setValueFormatter(formatter);
|
||||
|
||||
RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<Score>(results, "scoreNr", "totalScore");
|
||||
lineDataSet.setDrawCubic(false);
|
||||
lineDataSet.setLabel("Realm LineDataSet");
|
||||
lineDataSet.setLabel("Result Scores");
|
||||
lineDataSet.setDrawCircleHole(false);
|
||||
lineDataSet.setColor(ColorTemplate.rgb("#FF5722"));
|
||||
lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722"));
|
||||
|
@ -89,7 +110,7 @@ public class RealmWikiExample extends RealmBaseActivity {
|
|||
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
|
||||
dataSets.add(lineDataSet);
|
||||
|
||||
RealmLineData lineData = new RealmLineData(results, "scoreNr", "playerName", dataSets);
|
||||
LineData lineData = new LineData(dataSets);
|
||||
styleData(lineData);
|
||||
|
||||
// set data
|
||||
|
@ -98,14 +119,14 @@ public class RealmWikiExample extends RealmBaseActivity {
|
|||
|
||||
|
||||
// BAR-CHART
|
||||
RealmBarDataSet<Score> barDataSet = new RealmBarDataSet<Score>(results, "totalScore", "scoreNr");
|
||||
RealmBarDataSet<Score> barDataSet = new RealmBarDataSet<Score>(results, "scoreNr", "totalScore");
|
||||
barDataSet.setColors(new int[]{ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
|
||||
barDataSet.setLabel("Realm BarDataSet");
|
||||
|
||||
ArrayList<IBarDataSet> barDataSets = new ArrayList<IBarDataSet>();
|
||||
barDataSets.add(barDataSet);
|
||||
|
||||
RealmBarData barData = new RealmBarData(results, "scoreNr", "playerName", barDataSets);
|
||||
BarData barData = new BarData(barDataSets);
|
||||
styleData(barData);
|
||||
|
||||
barChart.setData(barData);
|
||||
|
|
|
@ -10,14 +10,14 @@ public class Score extends RealmObject {
|
|||
|
||||
private float totalScore;
|
||||
|
||||
private int scoreNr;
|
||||
private float scoreNr;
|
||||
|
||||
private String playerName;
|
||||
|
||||
public Score() {
|
||||
}
|
||||
|
||||
public Score(float totalScore, int scoreNr, String playerName) {
|
||||
public Score(float totalScore, float scoreNr, String playerName) {
|
||||
this.scoreNr = scoreNr;
|
||||
this.playerName = playerName;
|
||||
this.totalScore = totalScore;
|
||||
|
@ -33,11 +33,11 @@ public class Score extends RealmObject {
|
|||
this.totalScore = totalScore;
|
||||
}
|
||||
|
||||
public int getScoreNr() {
|
||||
public float getScoreNr() {
|
||||
return scoreNr;
|
||||
}
|
||||
|
||||
public void setScoreNr(int scoreNr) {
|
||||
public void setScoreNr(float scoreNr) {
|
||||
this.scoreNr = scoreNr;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ public abstract class RealmBarLineScatterCandleBubbleDataSet<T extends RealmObje
|
|||
* Constructor that takes the realm RealmResults, sorts & stores them.
|
||||
*
|
||||
* @param results
|
||||
* @param xValuesField
|
||||
* @param yValuesField
|
||||
* @param xIndexField
|
||||
*/
|
||||
public RealmBarLineScatterCandleBubbleDataSet(RealmResults<T> results, String yValuesField, String xIndexField) {
|
||||
super(results, yValuesField, xIndexField);
|
||||
public RealmBarLineScatterCandleBubbleDataSet(RealmResults<T> results, String xValuesField, String yValuesField) {
|
||||
super(results, xValuesField, yValuesField);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,12 +48,12 @@ public abstract class RealmBaseDataSet<T extends RealmObject, S extends Entry> e
|
|||
protected float mXMin = 0.0f;
|
||||
|
||||
/**
|
||||
* fieldname of the column that contains the yPx-values of this dataset
|
||||
* fieldname of the column that contains the y-values of this dataset
|
||||
*/
|
||||
protected String mYValuesField;
|
||||
|
||||
/**
|
||||
* fieldname of the column that contains the xPx-values of this dataset
|
||||
* fieldname of the column that contains the x-values of this dataset
|
||||
*/
|
||||
protected String mXValuesField;
|
||||
|
||||
|
@ -70,13 +70,13 @@ public abstract class RealmBaseDataSet<T extends RealmObject, S extends Entry> e
|
|||
* Constructor that takes the realm RealmResults, sorts & stores them.
|
||||
*
|
||||
* @param results
|
||||
* @param xValuesField
|
||||
* @param yValuesField
|
||||
* @param xIndexField
|
||||
*/
|
||||
public RealmBaseDataSet(RealmResults<T> results, String yValuesField, String xIndexField) {
|
||||
public RealmBaseDataSet(RealmResults<T> results, String xValuesField, String yValuesField) {
|
||||
this.results = results;
|
||||
this.mYValuesField = yValuesField;
|
||||
this.mXValuesField = xIndexField;
|
||||
this.mXValuesField = xValuesField;
|
||||
this.mValues = new ArrayList<S>();
|
||||
|
||||
if (mXValuesField != null)
|
||||
|
@ -97,8 +97,7 @@ public abstract class RealmBaseDataSet<T extends RealmObject, S extends Entry> e
|
|||
public S buildEntryFromResultObject(T realmObject, float x) {
|
||||
DynamicRealmObject dynamicObject = new DynamicRealmObject(realmObject);
|
||||
|
||||
return (S) new Entry(dynamicObject.getFloat(mYValuesField),
|
||||
mXValuesField == null ? x : dynamicObject.getInt(mXValuesField));
|
||||
return (S) new Entry(mXValuesField == null ? x : dynamicObject.getFloat(mXValuesField), dynamicObject.getFloat(mYValuesField));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ public abstract class RealmLineScatterCandleRadarDataSet<T extends RealmObject,
|
|||
/** the path effect for dashed highlight-lines */
|
||||
protected DashPathEffect mHighlightDashPathEffect = null;
|
||||
|
||||
|
||||
public RealmLineScatterCandleRadarDataSet(RealmResults<T> results, String yValuesField) {
|
||||
super(results, yValuesField);
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ public class RealmBarDataSet<T extends RealmObject> extends RealmBarLineScatterC
|
|||
"Stack"
|
||||
};
|
||||
|
||||
public RealmBarDataSet(RealmResults<T> results, String yValuesField, String xIndexField) {
|
||||
super(results, yValuesField, xIndexField);
|
||||
public RealmBarDataSet(RealmResults<T> results, String xValuesField, String yValuesField) {
|
||||
super(results, xValuesField, yValuesField);
|
||||
mHighLightColor = Color.rgb(0, 0, 0);
|
||||
|
||||
build(this.results);
|
||||
|
@ -59,13 +59,13 @@ public class RealmBarDataSet<T extends RealmObject> extends RealmBarLineScatterC
|
|||
* Constructor for supporting stacked values.
|
||||
*
|
||||
* @param results
|
||||
* @param xValuesField
|
||||
* @param yValuesField
|
||||
* @param xIndexField
|
||||
* @param stackValueFieldName
|
||||
*/
|
||||
public RealmBarDataSet(RealmResults<T> results, String yValuesField, String xIndexField, String
|
||||
public RealmBarDataSet(RealmResults<T> results, String xValuesField, String yValuesField, String
|
||||
stackValueFieldName) {
|
||||
super(results, yValuesField, xIndexField);
|
||||
super(results, xValuesField, yValuesField);
|
||||
this.mStackValueFieldName = stackValueFieldName;
|
||||
mHighLightColor = Color.rgb(0, 0, 0);
|
||||
|
||||
|
@ -97,10 +97,10 @@ public class RealmBarDataSet<T extends RealmObject> extends RealmBarLineScatterC
|
|||
}
|
||||
|
||||
return new BarEntry(
|
||||
mXValuesField == null ? x : dynamicObject.getInt(mXValuesField), values);
|
||||
mXValuesField == null ? x : dynamicObject.getFloat(mXValuesField), values);
|
||||
} else {
|
||||
float value = dynamicObject.getFloat(mYValuesField);
|
||||
return new BarEntry(mXValuesField == null ? x : dynamicObject.getInt(mXValuesField), value);
|
||||
return new BarEntry(mXValuesField == null ? x : dynamicObject.getFloat(mXValuesField), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RealmBubbleDataSet<T extends RealmObject> extends RealmBarLineScatt
|
|||
DynamicRealmObject dynamicObject = new DynamicRealmObject(realmObject);
|
||||
|
||||
return new BubbleEntry(
|
||||
mXValuesField == null ? x : dynamicObject.getInt(mXValuesField),
|
||||
mXValuesField == null ? x : dynamicObject.getFloat(mXValuesField),
|
||||
dynamicObject.getFloat(mYValuesField),
|
||||
dynamicObject.getFloat(mSizeField));
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public class RealmCandleDataSet<T extends RealmObject> extends RealmLineScatterC
|
|||
DynamicRealmObject dynamicObject = new DynamicRealmObject(realmObject);
|
||||
|
||||
return new CandleEntry(
|
||||
mXValuesField == null ? xIndex : dynamicObject.getInt(mXValuesField),
|
||||
mXValuesField == null ? xIndex : dynamicObject.getFloat(mXValuesField),
|
||||
dynamicObject.getFloat(mHighField),
|
||||
dynamicObject.getFloat(mLowField),
|
||||
dynamicObject.getFloat(mOpenField),
|
||||
|
|
|
@ -87,11 +87,11 @@ public class RealmLineDataSet<T extends RealmObject> extends RealmLineRadarDataS
|
|||
* Constructor for creating a LineDataSet with realm data.
|
||||
*
|
||||
* @param result the queried results from the realm database
|
||||
* @param yValuesField the name of the field in your data object that represents the yPx-yValue
|
||||
* @param xIndexField the name of the field in your data object that represents the xPx-index
|
||||
* @param xValuesField the name of the field in your data object that represents the x-axis value
|
||||
* @param yValuesField the name of the field in your data object that represents the y-axis value
|
||||
*/
|
||||
public RealmLineDataSet(RealmResults<T> result, String yValuesField, String xIndexField) {
|
||||
super(result, yValuesField, xIndexField);
|
||||
public RealmLineDataSet(RealmResults<T> result, String xValuesField, String yValuesField) {
|
||||
super(result, xValuesField, yValuesField);
|
||||
mCircleColors = new ArrayList<Integer>();
|
||||
|
||||
// default color
|
||||
|
|
|
@ -48,20 +48,6 @@ public class RealmPieDataSet<T extends RealmObject> extends RealmBaseDataSet<T,
|
|||
calcMinMax();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for creating a PieDataSet with realm data.
|
||||
*
|
||||
* @param result the queried results from the realm database
|
||||
* @param yValuesField the name of the field in your data object that represents the yPx-yValue
|
||||
* @param xIndexField the name of the field in your data object that represents the xPx-index
|
||||
*/
|
||||
public RealmPieDataSet(RealmResults<T> result, String yValuesField, String xIndexField) {
|
||||
super(result, yValuesField, xIndexField);
|
||||
|
||||
build(this.results);
|
||||
calcMinMax();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the space that is left out between the piechart-slices in dp.
|
||||
* Default: 0 --> no space, maximum 20f
|
||||
|
|
|
@ -45,11 +45,11 @@ public class RealmRadarDataSet<T extends RealmObject> extends RealmLineRadarData
|
|||
* Constructor for creating a RadarDataSet with realm data.
|
||||
*
|
||||
* @param result the queried results from the realm database
|
||||
* @param yValuesField the name of the field in your data object that represents the yPx-yValue
|
||||
* @param xIndexField the name of the field in your data object that represents the xPx-index
|
||||
* @param xValuesField the name of the field in your data object that represents the x value
|
||||
* @param yValuesField the name of the field in your data object that represents the y value
|
||||
*/
|
||||
public RealmRadarDataSet(RealmResults<T> result, String yValuesField, String xIndexField) {
|
||||
super(result, yValuesField, xIndexField);
|
||||
public RealmRadarDataSet(RealmResults<T> result, String xValuesField, String yValuesField) {
|
||||
super(result, xValuesField, yValuesField);
|
||||
|
||||
build(this.results);
|
||||
calcMinMax();
|
||||
|
|
|
@ -57,11 +57,11 @@ public class RealmScatterDataSet<T extends RealmObject> extends RealmLineScatter
|
|||
* Constructor for creating a ScatterDataSet with realm data.
|
||||
*
|
||||
* @param result the queried results from the realm database
|
||||
* @param yValuesField the name of the field in your data object that represents the yPx-yValue
|
||||
* @param xIndexField the name of the field in your data object that represents the xPx-index
|
||||
* @param xValuesField the name of the field in your data object that represents the x value
|
||||
* @param yValuesField the name of the field in your data object that represents the y value
|
||||
*/
|
||||
public RealmScatterDataSet(RealmResults<T> result, String yValuesField, String xIndexField) {
|
||||
super(result, yValuesField, xIndexField);
|
||||
public RealmScatterDataSet(RealmResults<T> result, String xValuesField, String yValuesField) {
|
||||
super(result, xValuesField, yValuesField);
|
||||
|
||||
build(this.results);
|
||||
calcMinMax();
|
||||
|
|
Loading…
Add table
Reference in a new issue