time series as input to x-Axis data

47 views
Skip to first unread message

naveen kumar

unread,
Feb 10, 2011, 6:24:29 AM2/10/11
to ChartDroid Users
i downloaded with chartdroid demo
but how to deal with date and time as input for x-Axis data.
can anyone help..?

thanks

Avinash M

unread,
Feb 10, 2011, 7:05:23 PM2/10/11
to ChartDroid Users
Convert your date and time to Milliseconds and feed to graph.
But on the graph only date will be displayed.

You can use DateFormat available in Java.
Here is the snippet of the code.

public static long StringToDate(String str_date) {
long lDate = 0;
try {
DateFormat formatter ;
Date date_obj ;
formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
date_obj = (Date)formatter.parse(str_date);
Calendar cal=Calendar.getInstance();
cal.setTime(date_obj);
lDate = cal.getTimeInMillis();
} catch (ParseException e) {
System.out.println("Exception :"+e);
}
return lDate;
}

Feed this lDate as input for x-axis to DataContentProvider.
Hope this solves your issue.

naveen kumar

unread,
Feb 10, 2011, 11:18:41 PM2/10/11
to chartdro...@googlegroups.com
its working, But in graph on x-Axis it not displaying date format ,its displaying in 1.29728E12 (format) in milliseconds i think
how to solve this?

 

Avinash M

unread,
Feb 11, 2011, 12:37:18 AM2/11/11
to ChartDroid Users
Check in your ContentProvider whether the data you are sending for x-
axis is of type long.
You need to send your x-axis data in Long format.

And yes, dont forget to change your getType() in ContentProvider to
return ColumnSchema.EventData.CONTENT_TYPE_PLOT_DATA
instead of ColumnSchema.PlotData.CONTENT_TYPE_PLOT_DATA.

This should work.

naveen kumar

unread,
Feb 11, 2011, 1:19:12 AM2/11/11
to chartdro...@googlegroups.com

i am sending X-Axis data in Long Format only...

i change  getType() in ContentProvider to
return ColumnSchema.EventData.CONTENT_TYPE_PLOT_DATA
then its showing "there is no series!"
 
if i change getType() in ContentProvider to
return ColumnSchema.PlotData.CONTENT_TYPE_PLOT_DATA
it shows graph but it displays the x-Axis in 1.29728E12 (format)

Karl Ostmo

unread,
Feb 11, 2011, 2:29:21 AM2/11/11
to chartdro...@googlegroups.com

Hylke van der Schaaf

unread,
Sep 27, 2012, 9:09:08 AM9/27/12
to chartdro...@googlegroups.com
Currently the date format for the x-axis of timeline graphs is fixed to the ambiguous US date format. You can specify the format for the y-axis, and the format for the x-axis of all other chart types, but not for the x-axis of timeline graphs.

Could you either allow the date format to be overridden, use a locale-dependent format, or at least use a non-ambiguous format like ISO 8601?

Hylke
Reply all
Reply to author
Forward
0 new messages