I am using GraphView I need to display the graph points concurrently as real time. But problem is, it's displaying the graph as completely. But my requirement is, it should plot the graph concurrently.
As per the suggested one, I modified based on my requirement but it's not displaying as real time graph plot.
public class MainActivity extends AppCompatActivity {
private LineGraphSeries<DataPoint> mSeries1;
private Runnable mTimer1;
private final Handler mHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GraphView graph = (GraphView) findViewById(R.id.graph);
mSeries1 = new LineGraphSeries<>(generateData());
graph.addSeries(mSeries1);
}
private DataPoint[] generateData() {
DataPoint[] dataPoint= new DataPoint[]{
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 4),
new DataPoint(3, 6),
new DataPoint(4, 8),
new DataPoint(5, 10),
};
return dataPoint;
}
@Override
protected void onResume() {
super.onResume();
mTimer1 = new Runnable() {
@Override
public void run() {
mSeries1.resetData(generateData());
mHandler.postDelayed(this, 300);
}
};
mHandler.postDelayed(mTimer1, 300);
}
@Override
public void onPause() {
mHandler.removeCallbacks(mTimer1);
super.onPause();
}
}
in Xml:
<com.jjoe64.graphview.GraphView
android:layout_width="match_parent"
android:layout_height="200dip"
android:id="@+id/graph" />