[英]Google Visualization - AnnotatedTimeLine SQL
hi everyone i am trying to figure out how this is going to work.大家好,我想弄清楚这是如何工作的。 i dont know why i am always getting a blank page我不知道为什么我总是得到一个空白页
Heres my code这是我的代码
from the index.html来自索引.html
<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>
And from my vis.php从我的 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();
?>
Can anyone tell me where did i miss out?谁能告诉我我错过了哪里? I am always getting into a blank page我总是进入一个空白页
I have experienced this problem before.我以前遇到过这个问题。 You need to change this..你需要改变这个..
query.setQuery('select thedate,visits,sales from dothefetch');
.. to this: ..对此:
query.setQuery('select *');
This should work.这应该有效。 If not, try to fix the preg_quote issue: https://code.google.com/p/mc-goog-visualization/issues/detail?id=16如果没有,请尝试修复 preg_quote 问题: https://code.google.com/p/mc-goog-visualization/issues/detail?id=16
EDIT: The same problem as yours could be seen here: Google Vis annotated timeline from SQL database using PHP JSON issue编辑:在这里可以看到与您相同的问题: Google Vis annotated timeline from SQL database using PHP JSON issue
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.