0

I'm currently making an app that tracks a user's blood pressure. Right now, I have a dataset with data programmed into the graph instead of a user actually inputting information. How would I store an integer and use it as a new data point in the graph?

ArrayList<Entry> yValues = new ArrayList<>();

yValues.add(new Entry(1, 133f));
yValues.add(new Entry(2, 134f));
yValues.add(new Entry(3, 133f));
yValues.add(new Entry(4, 130f));
yValues.add(new Entry(5, 128f));
yValues.add(new Entry(6, 130f));
yValues.add(new Entry(7, 125f));
yValues.add(new Entry(8, 125f));
yValues.add(new Entry(9, 117f));
yValues.add(new Entry(10, 124f));


LineDataSet set1 = new LineDataSet(yValues, "Systolic Blood Pressure");


ArrayList<ILineDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);

LineData data = new LineData(dataSets);

//set data into mChart
mChart.setData(data);

I have this, but I want the user to input their data themselves instead of through code.

rsm
  • 2,530
  • 4
  • 26
  • 33
JDoza
  • 1
  • 1

1 Answers1

0
  1. Create an edit text and get value from user e.g 127
  2. Store this to float variable e.g float

    value = Float.valueOf(edittext.getText.toString())
    
  3. then

    yValues.add(new Entry(yValues.size+1, value));
    
  4. then call

    dataset.invalidate();
    chart.notifyDatasetChanged();
    chart.invalidate();
    
Muhammad Saad Rafique
  • 3,158
  • 1
  • 13
  • 21