annotated time line Date format & data from MySQL

765 views
Skip to first unread message

shaikha

unread,
Apr 3, 2009, 9:30:18 AM4/3/09
to Google Visualization API
i tried to display the script annotated time line chart data from my
database data mysql

the date format in annotated time line chart as yyyy,mm,dd
and in mysql data i have 2 date one is formated as long Date and the
other is formated as String Date

any one has idea how to change the date format and how to insert the
data to annotated time line chart

JDRopp

unread,
Apr 3, 2009, 4:19:15 PM4/3/09
to Google Visualization API
Here's my sample code (PHP and MySQL):

$sql = "select Date, UNIX_TIMESTAMP(Date) as 'unixdate',........
echo "data.setValue(" . $i . ", 0, new Date(" . date ("Y , m , d",
mysql_result ( $result, $i, 'unixdate')) . "));\n";

sh al

unread,
Apr 8, 2009, 7:01:52 AM4/8/09
to google-visua...@googlegroups.com

this is my code where is my mistakes,   do u know ??
 
 

{

var data = new google.visualization.DataTable();

data.addColumn(

'datetime', 'Date'); // Column 0 is type string and has label "Date".

data.addColumn(

'number', 'Temperature');

data.addColumn(

'string', 'title1');

data.addColumn(

'string', 'text1');

data.addColumn(

'number', 'Humidity');

data.addColumn(

'string', 'title2');

data.addColumn(

'string', 'text2');

<% int counter=0;

try{%>

<%

while(db.rs.next()) {%>

data.setValue(

<%=counter%>, 0, new Date(<%=db.rs.getInt(5)%>,<%=db.rs.getInt(6)%>,<%=db.rs.getInt(7)%>,<%=db.rs.getInt(8)%>,<%=db.rs.getInt(9)%>,<%=db.rs.getInt(10)%> )); // Row 0, column 0

data.setValue(

<%=counter%>, 1, <%=db.arrayChartData[0]%>);

data.setValue(

<%=counter%>, 4, <%=db.arrayChartData[1]%>);

<% counter++;} }catch(Exception e){}%>

VizGuy

unread,
Apr 9, 2009, 4:46:50 PM4/9/09
to google-visua...@googlegroups.com
This is of course not an Annotated time line issue, but a general problem of converting SQL dates into js dates.
Once you succeed to create a data table, with a valid date or datetime column, and a valid js Date object in the value, you should be good.

I would recommend starting with a non sql based example, to make sure that all of the rest is good, and then work on converting the SQL dates to js ones.

Regards,
VizGuy

sh al

unread,
Apr 12, 2009, 1:29:59 PM4/12/09
to google-visua...@googlegroups.com
okk u don't have any example, to help me in this chart ,,,,,,
 
 
thank you all for helping me

Rolan

unread,
Apr 12, 2009, 1:40:32 PM4/12/09
to Google Visualization API
On Apr 9, 4:46 pm, VizGuy <viz...@google.com> wrote:
> This is of course not an Annotated time line issue, but a general problem of
> converting SQL dates into js dates.Once you succeed to create a data table,
> with a valid date or datetime column, and a valid js Date object in the
> value, you should be good.
...


To save some trouble, here's is a code snippet:

/**
* converts "m/d/Y hh:mm" into a Date object
*/
function convertDate(datetime) {
var tmp=datetime.split(' ');
var dt=tmp[0].split('/');
var t=tmp[1].split(':');
var d = new Date;
d.setFullYear(dt[2],(dt[0]-1),dt[1]);
d.setHours(t[0],t[1],0,0);
return d;
}


Also, I think the API for the Annotated Time Line gadget changed
recently. The time display on top of the graph began to only show the
"Date" and not "Time+Date". Turns out, now you have to specify the
DateFormat as an option when calling the draw method.

chart.draw(data, {displayAnnotations: true,dateFormat: 'HH:mm MMMM dd,
yyyy'});

~Rolan

sh al

unread,
Apr 12, 2009, 2:03:08 PM4/12/09
to google-visua...@googlegroups.com
Thank you ,,,,,, but can u tel me how do i submit the date time
         data.setValue(0, 0, new Date(2009,2,31,15,23,0)); // Row 0, column 0, date

year 2009,  month 2 , date 31, hour 3 , mins 23, second 0


is that right or instead of , i type / ???

sh al

unread,
Apr 12, 2009, 2:15:43 PM4/12/09
to google-visua...@googlegroups.com
'HH:mm MMMM dd,yyyy'}
or i have to type hours : mins  space April 15,2009 ???


or ?????

sh al

unread,
Apr 12, 2009, 2:17:02 PM4/12/09
to google-visua...@googlegroups.com
i mean in setValue (year, month , date )
which format do i have to use
Reply all
Reply to author
Forward
0 new messages