private void setData() { RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class); RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "value", "xIndex"); // set.setDrawCubic(false); set.setLabel("次数"); // set.setDrawCircleHole(false); set.setColor(getResourcesColor(R.color.gold)); set.setCircleColor(getResourcesColor(R.color.gold)); set.setHighLightColor(Color.WHITE); set.setLineWidth(1.8f); set.setCircleSize(3.6f); set.setValueTextColor(Color.WHITE); ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); dataSets.add(set); // add the dataset // create a data object with the dataset list RealmLineData data = new RealmLineData(result, "xValue", dataSets); styleData(data); // set data mChart.setData(data); mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); }
/** * 初始化线 */ private void initLine() { RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class); RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "value", "xIndex"); set.setLabel("次数"); set.setColor(getResourcesColor(R.color.gold)); set.setCircleColor(getResourcesColor(R.color.gold)); set.setHighLightColor(Color.WHITE); set.setLineWidth(1.8f); set.setCircleSize(3.6f); set.setValueTextColor(Color.WHITE); ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); dataSets.add(set); // add the dataset RealmLineData data = new RealmLineData(result, "xValue", dataSets); styleData(data); mChart.setData(data); mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); }
private void setData() { RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class); RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "value", "xIndex"); set.setDrawCubic(false); set.setLabel("Realm LineDataSet"); set.setDrawCircleHole(false); set.setColor(ColorTemplate.rgb("#FF5722")); set.setCircleColor(ColorTemplate.rgb("#FF5722")); set.setLineWidth(1.8f); set.setCircleSize(3.6f); ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); dataSets.add(set); // add the dataset // create a data object with the dataset list RealmLineData data = new RealmLineData(result, "xValue", dataSets); styleData(data); // set data mChart.setData(data); mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); }
private void setData() { // LINE-CHART RealmResults<Score> results = mRealm.allObjects(Score.class); RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<Score>(results, "totalScore", "scoreNr"); lineDataSet.setDrawCubic(false); lineDataSet.setLabel("Realm LineDataSet"); lineDataSet.setDrawCircleHole(false); lineDataSet.setColor(ColorTemplate.rgb("#FF5722")); lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722")); lineDataSet.setLineWidth(1.8f); lineDataSet.setCircleSize(3.6f); ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); dataSets.add(lineDataSet); RealmLineData lineData = new RealmLineData(results, "playerName", dataSets); styleData(lineData); // set data lineChart.setData(lineData); lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); // BAR-CHART RealmBarDataSet<Score> barDataSet = new RealmBarDataSet<Score>(results, "totalScore", "scoreNr"); 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, "playerName", barDataSets); styleData(barData); barChart.setData(barData); barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); }