I have my method to retrieve data from sqlite data using rawQuery. But now I don't know how to put it in the graph view,( for ex: all date and all weight column) put in the graphview
Here is the code to retrieve data
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();
and this is my graphview , and how can i use the retrieve data method that I have and add or combine the data to implement in my 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();
}