Google可视化显示问题 [英] Google Visualization Display Issue

查看:159
本文介绍了Google可视化显示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程式中使用Google Charts Visualization API,发生图表无法载入的问题。



当我加载我的应用程序而没有从工作副本进行任何先前的更改,并且没有在页面上加载Javascript图表时,问题第一次发生。我检查了Chrome和FireFox控制台错误,它们如下:

  Firefox:ReferenceError:dr is not definedin loader.js 
Chrome:Uncaught TypeError:google.visualization.PieChart不是函数

这里是我的代码用于绘制我的两个图表。

 < script type =text / javascriptsrc =https://www.gstatic .com / charts / loader.js>< / script> 
< script type =text / javascript>
google.charts.load('current',{'package':['corechart','table']});


google.charts.setOnLoadCallback(drawChart);
function drawChart(){


var data = new google.visualization.DataTable();
data.addColumn('string','Signatures');
data.addColumn('number','Number of Occurnce');

for(i = 0; i data.addRow([num [i],parseInt(num [i + 1])]
i ++;
}


var options = {
title:'Top 5 Alerts'
};

var chart = new google.visualization.PieChart(document.getElementById('piechart'));

chart.draw(data,options);
}
< / script>

这是我在页面头部加载的JQuery。

 < script src =https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js> < / script> 

浏览Google Charts官方网站后:



https://developers.google.com/chart/ interactive / docs / gallery / piechart



我注意到PieChart Google正在试图加载他们的例子将不能在我的机器上使用相同的Firefox和Chrome控制台错误。



我不知道从这里开始去哪里,想知道mayby是否可以阻止我的IP加载API等等?



或者如果设置已更改,现在阻止了图表加载?



任何洞察到这可能发生的情况将是一个很大的帮助。

解决方案

您可能遇到了最新版本 ...


当我们推出一个新版本,在系统中有一些打嗝,直到更改完全传播。我们将在以后解决这个问题,但现在,如果你得到这些类型的错误,我建议你刷新页面,如果必要刷新缓存。

你也可以改变'current'到'43'或'44',它将工作更可靠。


从这里找到 - > Google可视化图表API示例已损坏



此示例适用于我在Chrome中,没有看到任何差异,是否有更多的代码可以共享?



ve也遇到问题加载 JQuery和Google图表



  google.charts.load('current',{packages:['corechart','table']}); google.charts.setOnLoadCallback(drawChart); function drawChart(){var data = new google.visualization .DataTable(); data.addColumn('string','Signatures'); data.addColumn('number','Number of Occurnce'); for(i = 1; i <11; i ++){data.addRow([i.toString(),parseInt(i + 1)]); } var options = {title:'Top 5 Alerts'}; var chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data,options);}  

  script src =https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js>< / script>< script src =https://www.gstatic .com / charts / loader.js>< / script>< div id =piechart>< / div>  

/ div>


I am using Google Charts Visualization API in my application and have encountered a problem whereby the charts are failing to load.

The problem first occurred when I loaded my application without making any prior changes from a working copy and the Javascript Charts were not loaded on the page. I checked the Chrome and FireFox console errors and they are as follows:

Firefox: ReferenceError: dr is not definedin loader.js
Chrome: Uncaught TypeError: google.visualization.PieChart is not a function

Here is my code for drawing my two charts.

 <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
                <script type="text/javascript">
                    google.charts.load('current', { 'packages': ['corechart', 'table'] });


                    google.charts.setOnLoadCallback(drawChart);
                    function drawChart() {


                        var data = new google.visualization.DataTable();
                        data.addColumn('string', 'Signatures');
                        data.addColumn('number', 'Number of Occurence');

                        for (i = 0; i < num.length; i++) {
                            data.addRow([num[i], parseInt(num[i + 1])]);
                            i++;
                        }


                        var options = {
                            title: 'Top 5 Alerts'
                        };

                        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

                        chart.draw(data, options);
                    }
                </script>

Here is the JQuery I load within the head of the page.

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

After digging around and heading to the Google Charts official site here:

https://developers.google.com/chart/interactive/docs/gallery/piechart

I noticed the PieChart Google is attempting to load for their example will not work on my machine either with the same Firefox and Chrome console errors.

I am not sure where to go from here and was wondering if mayby Google could be blocking my IP from loading the API or such?

Or if settings have been changed which are now preventing the charts from loading?

Any insight into why this might be happening would be a great help.

解决方案

you may be experiencing problems from the latest release...

It appears that when we push out a new version, there are some hiccups in the system until the changes fully propagate. We will be working to fix this in the future, but for now, if you get these kinds of errors, I suggest you refresh the page, flushing your cache if necessary.
You can also change 'current' to '43' or '44' and it will work more reliably.

found from here --> Google Visualization Charts API examples are broken

this example works for me in Chrome, don't see any differences, is there more code you can share?

I've also seen problems loading both JQuery and GoogleCharts

google.charts.load('current', {
  packages: ['corechart', 'table']
});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Signatures');
  data.addColumn('number', 'Number of Occurence');

  for (i = 1; i < 11; i++) {
    data.addRow([i.toString(), parseInt(i + 1)]);
  }

  var options = {
    title: 'Top 5 Alerts'
  };

  var chart = new google.visualization.PieChart(document.getElementById('piechart'));
  chart.draw(data, options);
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="piechart"></div>

这篇关于Google可视化显示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆