As per now i have added values manually in this piece of code. But I need a graph according to the values I get from the instrument.This textview data is called from textview data in devicecontrolactivity class using intent. Have used MPandroidchartv3.0.3.
Thank you _/\_
public class GraphView extends Activity {
LineChart lineChart;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.streaming);
TextView textView = (TextView) findViewById(R.id.textview1);
Bundle b = getIntent().getExtras();
String received = b.getString("value");
//this textview contains the data which needs to be plotted
textView.setText(received);
//back button to get back to devicecontrolactivity
Button button = (Button) findViewById(R.id.buttoni);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
backActivity();
}
});
lineChart = (LineChart) findViewById(R.id.linegraph);
LineDataSet lineDataSet = new LineDataSet(datavalues(), "Data Set");
//Arraylist of linedatasets
ArrayList < ILineDataSet > dataSets = new ArrayList < > ();
dataSets.add(lineDataSet);
LineData Data = new LineData(dataSets);
lineChart.setData(Data);
lineChart.invalidate();
}
//intent method to get back to devicecontrolactivity
public void backActivity() {
Intent intent1 = new Intent(this, DeviceControlActivity.class);
startActivity(intent1);
}
//Array for dataentries for plotting data as linechart
public ArrayList < Entry > datavalues() {
ArrayList < Entry > datavals = new ArrayList < Entry > ();
datavals.add(new Entry(0, 20));
datavals.add(new Entry(1, 25));
datavals.add(new Entry(2, 30));
datavals.add(new Entry(3, 15));
return datavals;
}
}