开发者

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>
  <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

<?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 alway开发者_如何学Pythons 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

EDIT: The same problem as yours could be seen here: Google Vis annotated timeline from SQL database using PHP JSON issue

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜