因此,我从Firebase数据库中检索了“高度”数据。每当我添加一个高度数据时,它都应该绘制它并连接到以前的高度数据。
这是我的系列。
graph.addSeries(seriesheight);
seriesheight.setColor(Color.rgb(0,0,255));
seriesheight.setThickness(6);
seriesheight.setTitle("Height");
seriesheight.setDrawDataPoints(true);
seriesheight.setDataPointsRadius(8);
seriesheight.setOnDataPointTapListener(new OnDataPointTapListener() {
@Override
public void onTap(Series series, DataPointInterface dataPoint) {
Toast.makeText(getActivity(), dataPoint+ "\n" + date, Toast.LENGTH_SHORT).show();
}
});
这是我附加数据的地方
lastlastref.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String heightu = dataSnapshot.child("height").getValue(String.class);
date = dataSnapshot.child("time_stamp").getValue(String.class);
if (heightu != null) {
height = Double.parseDouble(heightu);
seriesheight.appendData(new DataPoint(months, height), true, 100);
lastlastref.keepSynced(true);
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
它仅连接到第二个数据。如何连接所有数据点?