• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Creating GridView graph

I have the following part of code:

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:

a9u1D.png


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:
First thing you should do, is verify what data is going into your array.
Set a breakpoint in the onClick() method, and step through the code. Are the data values what you expected?
 
Back
Top Bottom