0
我有我的方法來使用rawQuery從sqlite數據檢索數據。但現在我不知道如何把它的圖形視圖,(爲前:所有日期和所有的權重列)放在graphview如何在GraphView中實現我的sqlite數據?
這裏是代碼檢索數據
DBHelperNote connect = new DBHelperNote(AnalysisGraph.this);
SQLiteDatabase db = connect.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM weight;", null);
if (cursor.moveToNext()) {
d = cursor.getString(cursor.getColumnIndex("date"));
e = cursor.getString(cursor.getColumnIndex("weight"));
tv.setText(d);
tc.setText(d);
}
db.close();
和這是我的graphview,我如何使用我有的檢索數據方法,並添加或組合數據以在我的graphview中實現?
GraphView line_graph = (GraphView) contentView.findViewById(R.id.graph);
LineGraphSeries<DataPoint> line_series =
new LineGraphSeries<DataPoint>(new DataPoint[] {
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
});
line_graph.addSeries(line_series);
line_series.setDrawDataPoints(true);
line_series.setDataPointsRadius(10);
line_series.setOnDataPointTapListener(new OnDataPointTapListener() {
@Override
public void onTap(Series series, DataPointInterface dataPoint) {
Toast.makeText(getActivity(), "Series: On Data Point clicked: " + dataPoint, Toast.LENGTH_SHORT).show();
}
我的意思是我有我的數據在我的sqlite數據庫阿爾迪,我的我的方法來檢索和讀取數據,現在點是我怎麼能把數據這是得到和添加和結合在graphview因爲我需要像分析結果圖 –
ü可以使用任何庫來顯示圖形? –
如果你不能只使用mpandroidchart libaray它可以sutiable,你想要什麼。和esaly implement爲您的graphview .https://github.com/PhilJay/MPAndroidChart –