private void setData() { RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll(); RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(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<ILineDataSet>(); 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.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("次数"); // 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); }
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) { return results.get((int) value).getPlayerName(); } }; lineChart.getXAxis().setValueFormatter(formatter); barChart.getXAxis().setValueFormatter(formatter); RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<Score>(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<ILineDataSet>(); dataSets.add(lineDataSet); LineData lineData = new LineData(dataSets); styleData(lineData); // set data lineChart.setData(lineData); lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); // BAR-CHART 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); BarData barData = new BarData(barDataSets); styleData(barData); barChart.setData(barData); barChart.setFitBars(true); barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); }