TypeError: google.visualization is undefined

后端 未结 2 412
时光说笑
时光说笑 2021-01-04 02:30

I\'m trying to work with Google charts API, but I get an error I can\'t understand:

Here is my code:



        
2条回答
  •  不知归路
    2021-01-04 03:19

    Try this way. This is working fine for me

        var timeout;
        google.charts.load('current', { 'packages': ['corechart'] });
        $(document).ready(function(){
           timeout = setInterval(function () {
              if (google.visualization != undefined) {
                 drawChart();
                 clearInterval(timeout);
              }
           }, 300);
        });
    
        function drawChart(range, type) {
           var data = new google.visualization.DataTable();
        .....
        }
    

提交回复
热议问题