Sergei Mikhailovskii
Lurker
I
faced with the following problem: I need to build a graph. One of the axises is usual number and the second is date, which is kept in GregorianCalendar object. In fact, I need to add on this axis dates, for example 01.01.1000 and the distance between the dates should be proportional (for example 01.01.1000 and 02.01.1000 should be much closer to each other than 02.01.1000 and 03.03.1000). But I have no ideas how to do it. I had some thoughts about parsing this dates to string, but didn't invent anything further
Tried to do it in a such way:
But there's no constructor for DataPoint with GregorianCalendar and int
faced with the following problem: I need to build a graph. One of the axises is usual number and the second is date, which is kept in GregorianCalendar object. In fact, I need to add on this axis dates, for example 01.01.1000 and the distance between the dates should be proportional (for example 01.01.1000 and 02.01.1000 should be much closer to each other than 02.01.1000 and 03.03.1000). But I have no ideas how to do it. I had some thoughts about parsing this dates to string, but didn't invent anything further
Tried to do it in a such way:
Code:
createGraph.setOnClickListener(new View.OnClickListener() {
[USER=1021285]@override[/USER]
public void onClick(View v) {
Log.d(LOG_TAG, "--- Rows in myTable: ---");
SQLiteDatabase db = dbHelper.getWritableDatabase();
Cursor cursor = db.query("myTable",null,null,null,null,null,null);
ArrayList<Integer> pulses = new ArrayList<>();
ArrayList<Calendar> dates = new ArrayList<>();
if (cursor.moveToFirst()){
int idColIndex = cursor.getColumnIndex("id");
int idColPulse = cursor.getColumnIndex("pulse");
int dateColIndex = cursor.getColumnIndex("date");
int monthColIndex = cursor.getColumnIndex("month");
int yearColIndex = cursor.getColumnIndex("year");
do{
pulses.add(cursor.getInt(idColPulse));
dates.add(new GregorianCalendar(cursor.getInt(yearColIndex), cursor.getInt(monthColIndex), cursor.getInt(dateColIndex)));
}while (cursor.moveToNext());
cursor.close();
dbHelper.close();
}
DataPoint arr[] = new DataPoint[pulses.size()];
for (int i = 0; i<pulses.size();i++){
arr = new DataPoint(dates.get(i), pulses.get(i));
}
}
});
But there's no constructor for DataPoint with GregorianCalendar and int
Last edited by a moderator: