1

このコードをスクリプトに貼り付けるとどうなりますか:

https://code.google.com/apis/ajax/playground/?type=visualization#using_the_query_language

実行すると、次のエラーが表示されます。

ReferenceError: "google" が定義されていません。

?!

4

1 に答える 1

0

「GoogleVisualizationAPI」を最初にロードする必要があります。クイックスタートに従ってください。

以下のスニペットをコンピューター上のファイルにコピーし、ブラウザーで開いて、上記の円グラフを表示できます。

リンクからのコードのスニペット:

<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">

  // Load the Visualization API and the piechart package.
  google.load('visualization', '1.0', {'packages':['corechart']});

  // Set a callback to run when the Google Visualization API is loaded.
  google.setOnLoadCallback(drawChart);

  // Callback that creates and populates a data table,
  // instantiates the pie chart, passes in the data and
  // draws it.
  function drawChart() {
    // !!! Use Google Visualization API here !!!
  }
</script>

Google Visualization APIは、が呼び出された後にのみ使用できることに注意してください。drawChart

于 2013-02-08T09:01:23.007 に答える