2012-04-11 2 views
1

GoogleグラフのAPIをGoogleのDrupal 7モジュール(Googleグラフモジュールではありません)に含めるようにしています。私は、サービスを呼びしようとすると、しかし、私は得る:"クリアスコープでコンパイル&ゴースクリプトを実行しようとしました" - GoogleグラフAPIを使用したDrupalのエラー

  • 「クリアスコープに行くコンパイルとスクリプトを実行しようとすると、」 - Firefoxでエラーが発生しました。
  • 「応答を送信できませんでした:クロムの chrome.extension.onRequestリスナー/文書」ごとに複数回応答を送信できません。

コードは次のとおりです。

(function ($) { 

    Drupal.behaviors.exampleModule = { 
    attach: function (context, settings) { 
     // 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() { 

      // Create the data table. 
      var data = new google.visualization.DataTable(); 
      data.addColumn('string', 'Topping'); 
      data.addColumn('number', 'Slices'); 
      data.addRows([ 
      ['Mushrooms', 3], 
      ['Onions', 1], 
      ['Olives', 1], 
      ['Zucchini', 1], 
      ['Pepperoni', 2] 
      ]); 

      // Set chart options 
      var options = {'title':'How Much Pizza I Ate Last Night', 
         'width':400, 
         'height':300}; 

      // Instantiate and draw our chart, passing in some options. 
      var chart = new google.visualization.PieChart(document.getElementById('chart_div')); 
      chart.draw(data, options); 
     } 
     alert("test"); 
    } 
    }; 

})(jQuery); 

私はこの仕事を得るために何ができますか? -Thanks

答えて

0

私はそれを修正:

google.load('visualization', '1.0', {'packages':['corechart']});ラインがちょうど(function ($) {後、最初に呼び出さなければなりません。ソリューションは次のとおりです。

(function ($) { 
    // Load the Visualization API and the piechart package. 
    google.load('visualization', '1.0', {'packages':['corechart']}); 
    Drupal.behaviors.exampleModule = { 
    attach: function (context, settings) { 

     // 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() { 

      // Create the data table. 
      var data = new google.visualization.DataTable(); 
      data.addColumn('string', 'Topping'); 
      data.addColumn('number', 'Slices'); 
      data.addRows([ 
      ['Mushrooms', 3], 
      ['Onions', 1], 
      ['Olives', 1], 
      ['Zucchini', 1], 
      ['Pepperoni', 2] 
      ]); 

      // Set chart options 
      var options = {'title':'How Much Pizza I Ate Last Night', 
         'width':400, 
         'height':300}; 

      // Instantiate and draw our chart, passing in some options. 
      var chart = new google.visualization.PieChart(document.getElementById('chart_div')); 
      chart.draw(data, options); 
     } 
     alert("test"); 
    } 
    }; 

})(jQuery); 
関連する問題