-2

I want to make graph for line chart. so I refer achartEngine , here is my code :

int[] x = {1, 2, 3, 4, 5};
int[] y = {24, 33, 15, 20, 55};
TimeSeries serial = new TimeSeries("Line 1");
for (int i = 0 ; i < x.length ; i++) {
     serial.add(x[i], y[i]);
}

XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(serial);

no question so far , but I don't know how to replace array with int.

for example , I use sqlite like :

SQLiteDatabase db = dbhelper.getReadableDatabase();
String[] columns = {KEY_ID, TEMPER};  
Cursor cursor = db.query(TABLE_NAME, null, null);
int id = cursor.getColumnIndex(KEY_ID);
int ect = cursor.getColumnIndex(TEMPER);

I am in this situation , any suggestions for me?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
leona
  • 5
  • 4
  • for changing a value of array, you have to call it like this: `x[1] = 2;` . For example, you want to change the first item of your `x`array from `1` to `50`, do: `x[0] = 50`; ... – Opiatefuchs May 19 '17 at 08:43

1 Answers1

0

You don't need the array. Wherever you are using it, replace it with values read from the cursor:

int id = cursor.getColumnIndexOrThrow(KEY_ID);
int ect = cursor.getColumnIndexOrThrow(TEMPER);
while (cursor.moveToNext()) {
    serial.add(cursor.getInt(id), cursor.getInt(ect));
}
CL.
  • 173,858
  • 17
  • 217
  • 259