Ejemplo n.º 1
0
  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() {
    RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

    RealmLineDataSet<RealmDemoData> set =
        new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue");
    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); // TODO

    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);
  }