Need example for displaying chart which fetches values from local database

201 views
Skip to first unread message

Avinash M

unread,
Jan 6, 2011, 2:19:20 PM1/6/11
to ChartDroid Users
Hello,

I am a graduate student and have fair experience on Android.
I am developing an App which requires to generate charts from the data
stored on the database locally.
My X Axis values are Date in MM/DD/YYYY HH:MM format and Y Axis data
varies as there are many columns in the table(Y Axis values are all
integers). I need to take relevant columns from the table for Y Axis
values depending on the condition which data i need to display on the
chart.

In the examples provided I see all the data fetched are created on the
fly using MatrixCursor.
Example on fetching values from database to Chart would be very
helpful.
From Chartdroid wiki, I wasn't clear on this.

String[] projection = new String[] {
"ROWID AS " + BaseColumns._ID, // ROWID is the implicit Primary
Key generator in SQLite
MY_AXIS_INDEX_COLUMN + " AS " + "COLUMN_AXIS_INDEX",
MY_SERIES_INDEX_COLUMN + " AS " + "COLUMN_SERIES_INDEX",
...
};

Can you throw some light on how i can feed x axis values and y axis
values to chartdroid from the database.
Your help is appreciated.

Thanks,
Avinash Mohan

Karl Ostmo

unread,
Jan 8, 2011, 7:39:05 PM1/8/11
to chartdro...@googlegroups.com
In the ChartDroid Demo application, the user can populate a database with arbitrary values.  Here is the Content Provider code that is used in plotting those values:


Note that in the database, I have named the columns what ChartDroid expects to see (e.g. http://code.google.com/p/chartdroid/source/browse/trunk/client/src/com/googlecode/chartdroid/demo/provider/DatabaseStoredData.java#41).  However, you may create a VIEW in SQLite that translates your own column names to those column names ChartDroid expects.

Karl

Avinash M

unread,
Jan 30, 2011, 11:54:39 PM1/30/11
to ChartDroid Users
Thanks Karl.

Now I have encountered another issue.
I am able to fetch data and series but not axes.

I get the toast, "There are no series".
I wanted to display multi timeline series on the chart.

When debugged the query() method of ContentProvider, I am able to get
Series and Data but,
control doesnt go to Axes condition after Series condition
execution.In the logs, I can see both Series and Data are fetched
correctly.
After that control doesnt go to Axes condition to fetch axes data.I
see following error in the logs.

01-30 22:49:21.124: INFO/System.out(340): Series:[Systolic, Pulse,
Diastolic]
01-30 22:49:21.224: ERROR/ChartDroid(363): Error in chart; finishing
activity. Chart: null

I have passed the data in the format what chartdroid expects.But still
getting this error.
Followed the examples provided in the chartdroid sample applications.
But still couldnt trace what is causing the issue.

Need your help in removing this error.

--
Thanks,
Avinash Mohan

On Jan 8, 6:39 pm, Karl Ostmo <kos...@gmail.com> wrote:
> In the ChartDroid Demo application, the user can populate a database with
> arbitrary values.  Here is the Content Provider code that is used in
> plotting those values:
>
> http://code.google.com/p/chartdroid/source/browse/trunk/client/src/co...
>
> Note that in the database, I have named the columns what ChartDroid expects
> to see (e.g.http://code.google.com/p/chartdroid/source/browse/trunk/client/src/co...).
>  However, you may create a VIEW in SQLite that translates your own column
> names to those column names ChartDroid expects.
>
> <http://code.google.com/p/chartdroid/source/browse/trunk/client/src/co...>

Karl Ostmo

unread,
Feb 6, 2011, 3:19:52 AM2/6/11
to chartdro...@googlegroups.com
Are you providing your axes data via Intent extras or through a Cursor?

One strategy you can take is to download the source of ChartDroid and install your own version with Log.d() statements sprinkled in it.

Karl

Avinash M

unread,
Feb 6, 2011, 3:35:09 AM2/6/11
to chartdro...@googlegroups.com
Hi Karl,

Its working perfectly fine.
I m able to generate the chart successfully without issues.

---
Avinash Mohan

Chathura Samarasinghe

unread,
May 4, 2014, 6:53:00 AM5/4/14
to chartdro...@googlegroups.com, avina...@gmail.com
Hi Karl,

Im really new to chartdroid. can you share a sample code with me which reads data from a static array and plot a chart in chartdroid ? im really stuck in this point of time. 
can you help me ?
Reply all
Reply to author
Forward
0 new messages