예제 #1
0
  private void addEntry() {
    LineData data = mChart.getData();
    int year = 2015;

    if (data != null) {

      LineDataSet set = data.getDataSetByIndex(0);

      if (set == null) {
        set = createSet();
        data.addDataSet(set);
      }

      //            data.addXValue(mMonths[data.getXValCount() % 12] + " " + (year +
      // data.getXValCount() /12));

      //            data.addEntry(new Entry((float) (Math.random() * 40) + 30f, set.getEntryCount(),
      // 0));

      mChart.notifyDataSetChanged();

      mChart.setVisibleXRangeMaximum(120);
      mChart.moveViewToX(data.getXValCount() - 121);
    }
  }
예제 #2
0
  private void addEntry() {
    LineData data = mLineChart.getData();
    if (data != null) {
      LineDataSet set = data.getDataSetByIndex(0);
      if (set == null) {
        set = createSet();
        data.addDataSet(set);
      }
      // add a new random value
      float a = r.nextFloat() * (2.00f + 2.00f) - 2.0f;
      System.out.println(a);
      data.addXValue("");
      data.addEntry(new Entry(a, set.getEntryCount()), 0);

      mLineChart.notifyDataSetChanged();

      mLineChart.setVisibleXRange(6, 0);

      mLineChart.moveViewToX(data.getXValCount() - 7);
    }
  }