2011-06-02 103 views
0

嗨,大家好,我想弄清楚這將如何工作。我不知道爲什麼我總是在index.html谷歌可視化 - AnnotatedTimeLine SQL

<html> 
    <head> 
    <script type="text/javascript" src="http://www.google.com/jsapi"></script> 
    <script type="text/javascript"> 
     google.load("visualization", "1", {packages:["annotatedtimeline"]}); 
     google.setOnLoadCallback(drawChart); 
     function drawChart() { 
     //Tell Google Visualization where your script is 
     var query = new google.visualization.Query('/vis.php'); 
     query.setQuery('select thedate,visits,sales from dothefetch'); 
     query.send(function(result) { 
      if(result.isError()) { 
      alert(result.getDetailedMessage()); 
      } else { 
      var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div')); 
      chart.draw(result.getDataTable(), {'colors': ['green', 'blue'], displayAnnotations: true, 'zoomStartTime': new Date(2011, 3 ,1), 'zoomEndTime': new Date(2011, 3 ,2) }); 
      } 
     }); 
     } 
    </script> 
    </head> 

    <body> 
    <div id="chart_div"></div> 
    </body> 
</html> 

從我vis.php得到一個空白頁

繼承人我的代碼

<?php 
require_once 'lib/MC/Google/Visualization.php'; 

$user = 'root'; 
$db = new PDO('mysql:host=localhost;dbname=mywebsite',$user,''); 
$vis = new MC_Google_Visualization($db,'mysql'); 
/* 
foreach($db->query('SELECT * from total') as $row) { 
     print_r($row); 
    } 
*/ 

$vis->addEntity('dothefetch', array(
'fields' => array(
'thedate' => array('field' => 'thedate', 'type' => 'datetime'), 
'visits' => array('field' => 'visits', 'type' => 'number'), 
'sales' => array('field' => 'sales', 'type' => 'number') 
    ) 
)); 

$vis->setDefaultEntity('dothefetch'); 
$vis->handleRequest(); 
?> 

誰能告訴我在哪裏錯過了?我總是進入一個空白頁面

+0

這不會有什麼使用App Engine,不是嗎? – 2011-06-03 00:28:41

+0

你確定你的數據庫返回了什麼嗎?你試過打印結果嗎?他們看起來像什麼?另外,如果你只是轉儲result.getDataTable()會得到什麼? – oli 2011-06-04 02:44:51

回答