Sergei Mikhailovskii
Lurker
I have the following part of code:
Aim - to create graph from data, which is taken from Database. But when I run the program I see this:
So, nothing is added and at the same time some strange numbers are on x-axis. What is the matter?
Code:
createGraph.setOnClickListener(new View.OnClickListener() {
[USER=1021285]@override[/USER]
public void onClick(View v) {
Cursor cursor = database.query("myTable", null,null,null,null,null,null);
if (cursor.moveToFirst()){
int idPulseIndex = cursor.getColumnIndex("pulse");
int idDateIndex = cursor.getColumnIndex("date");
int idMonthIndex = cursor.getColumnIndex("month");
int idYearIndex = cursor.getColumnIndex("year");
Date date = new Date(cursor.getInt(idDateIndex), cursor.getInt(idMonthIndex), cursor.getInt(idYearIndex));
dates.add(date);
pulses.add(cursor.getInt(idPulseIndex));
}
DataPoint[] arr = new DataPoint[dates.size()];
for (int i = 0;i<arr.length;i++){
arr = new DataPoint(dates.get(i), pulses.get(i));
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(arr);
graphView.addSeries(series);
}
});
Aim - to create graph from data, which is taken from Database. But when I run the program I see this:
So, nothing is added and at the same time some strange numbers are on x-axis. What is the matter?
Last edited by a moderator: