im new to learning google visualization API, i facing a problem when i wan 
to create a timeline and get the data from mysql.
below is the source code:

*json1.php*

<?php
$host="localhost";
$user="root";
$password=""; 
$koneksi=mysql_connect($host,$user,$password) or die("Cannot Connect The 
Database");
mysql_select_db("chart");
 
$query = mysql_query('SELECT * FROM chart');
$table = array();
$table['cols'] = array(

array('label' => 'Date', 'type' => 'datetime'),
array('label' => 'November', 'type' => 'number'),
);
$rows = array();
while($r = mysql_fetch_assoc($query)) {
$temp = array();

$temp[] = array('v' => $r['date']);
$temp[] = array('v' => (int) $r['value']);
$rows[] = array('c' => $temp);
}

$table['rows'] = $rows;
$jsonTable = json_encode($table);
 
echo $jsonTable;
?>

*new3.php*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>Google Visualization API Sample</title>
  <script type="text/javascript" src="http://www.google.com/jsapi";></script>
  <script type="text/javascript">
    google.load('visualization', '1', {packages: ['annotatedtimeline']});
google.setOnLoadCallback(drawVisualization);
    function drawVisualization() {
     var json = $.ajax({
url: 'json1.php', 
dataType: 'json',
async: false
}).responseText;

var data = new google.visualization.DataTable(json);
var options = {
title: 'Chart 2013',
};
    
      var chart = new google.visualization.AnnotatedTimeLine(
          document.getElementById('chart'));
      chart.draw(data, {'displayAnnotations': true});
    }
    
  </script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="chart" style="width: 800px; height: 300px;"></div>
</body>

********
i found out that the date format of the json is 
"rows":[{"c":[{"v":"2013-08-06"},{"v":20}]}
but the google API is using js format, is it i need to change the date 
format?
and how? really no idea.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to