Google协作平台和Google图表工具

时间:2013-02-24 22:13:59

标签: google-visualization google-sites

我正在尝试在Google网站中添加Google Chart Tools信息中心。

问题是要在Google Site的html框中包含哪些代码。我使用下面的代码尝试了不同的变体,但我一直在

failed to load external URL jsapi

代码在直接加载的html文件中完美运行,但不在Google Site的html框中。

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     11],
          ['Eat',      2],
          ['Commute',  2],
          ['Watch TV', 2],
          ['Sleep',    7]
        ]);

        var options = {
          title: 'My Daily Activities'
        };

        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>