谷歌图表显示空白的白页

时间:2016-05-10 19:07:03

标签: javascript php jquery html google-visualization

我正在构建一个谷歌折线图。我已经通过php插入了我的数据,这就是html源代码的样子。我不能为我的生活找到为什么这只是显示一个白页。我把单词test放在那里以确保它正在加载并且“test”显示但没有别的。 Apache日志显示没有错误。我感谢任何帮助或建议!

<!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="refresh" content="180" >

<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("search", "1");
  google.load("jquery", "1.4.2");
  google.load("jqueryui", "1.7.2");
</script>
<script type="text/javascript">
//    google.charts.load('current', {'packages':['corechart']});
//    google.charts.setOnLoadCallback(drawChart);
google.load("visualization", "1", {packages:["corechart"], callback: drawChart});

      function drawChart() {

        var data = new google.visualization.DataTable(
data.addColumn('date', 'PollTime');
data.addColumn('number', 'Download');
data.addColumn('number', 'Upload');

data.addRows([ [new Date(2016, 5, 4, 0, 4), 294, 37],  [new Date(2016, 5, 4, 0, 13), 265, 34],  [new Date(2016, 5, 4, 0, 22), 236, 32],  [new Date(2016, 5, 4, 0, 31), 218, 33],  [new Date(2016, 5, 4, 0, 40), 225, 46],  [new Date(2016, 5, 4, 0, 49), 207, 41],  [new Date(2016, 5, 4, 0, 58), 184, 29],  [new Date(2016, 5, 4, 1, 7), 190, 31],  [new Date(2016, 5, 4, 1, 16), 181, 32],  [new Date(2016, 5, 4, 1, 25), 191, 31],  [new Date(2016, 5, 4, 1, 34), 174, 32],  [new Date(2016, 5, 4, 1, 43), 142, 32],  [new Date(2016, 5, 4, 1, 52), 135, 30],  [new Date(2016, 5, 4, 2, 1), 128, 23],  [new Date(2016, 5, 4, 2, 10), 118, 28],  ]););
 var options = {
          title: 'TelePacific Bandwidth Usage',
          width: 900,
          height: 500,
          hAxis: {
            format: 'M/d/yy HH:mm',
            gridlines: {count: 15}
          },
          vAxis: {
            gridlines: {color: 'none'},
            minValue: 0
          }
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));

        chart.draw(data, options);

        var button = document.getElementById('change');

        button.onclick = function () {

          // If the format option matches, change it to the new option,
          // if not, reset it to the original format.
          options.hAxis.format === 'M/d/yy' ?
          options.hAxis.format = 'MMM dd, yyyy' :
          options.hAxis.format = 'M/d/yy';

          chart.draw(data, options);
        };
      }

google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
test
<div id="chart_div" style="width: 500px; height: 400px;"></div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

语法错误。 LN         var data = new google.visualization.DataTable( 应该         var data = new google.visualization.DataTable();

然后删除         ); 在数据之后