Google 可视化(PieChart/LineChart)Jquery Ajax Firefox 问题
我在 Firefox 中遇到了一个错误,并进行了全面搜索,但似乎没有找到我遇到的问题的答案。
我的程序在 Chrome 和 IE 中运行良好,但 iframe 图表在 Firefox 中不起作用。
我使用处理程序,然后使用 jquery.ajax 来获取数据并运行脚本。
jQuery.ajax({
url: jQuery(this).attr("href"),
data: data,
dataType: 'script'
});
data = 饼图的所有信息和表格的所有信息。表格很好,但饼图 iframe 是空的。如果我按下退格按钮,就会显示饼图。这几乎就像饼图在 Firefox 中超出了范围。
除了我自己的数据之外,数据看起来像这样。这是从处理程序传递到 ajax 调用
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows(5);
data.setValue(0, 0, 'Work');
data.setValue(0, 1, 11);
data.setValue(1, 0, 'Eat');
data.setValue(1, 1, 2);
data.setValue(2, 0, 'Commute');
data.setValue(2, 1, 2);
data.setValue(3, 0, 'Watch TV');
data.setValue(3, 1, 2);
data.setValue(4, 0, 'Sleep');
data.setValue(4, 1, 7);
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 450, height: 300, title: 'My Daily Activities'});
还有其他人遇到过类似的问题吗?我知道数据传递正确并且所有内容都已收到,但 Firefox 似乎无法很好地处理 iframe。
如果有人有任何建议或想法,那就太好了,
谢谢
I have run into a bug with firefox and have searched all over and have not seemed to find the answer to an issue I have been having.
My program works great in Chrome and IE, but the iframe charts are not working in firefox.
I'm using a handler and then jquery.ajax to grab at the data and run the script.
jQuery.ajax({
url: jQuery(this).attr("href"),
data: data,
dataType: 'script'
});
data = all the information for a piechart and all the information for a table. The table is fine, but the pie chart iframe is empty. If I hit the backspace button then the piechart will show up. It's almost like the piechart is overshooting in firefox.
the data looks like this except with my own data. This is getting passed from the handler to the ajax call
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows(5);
data.setValue(0, 0, 'Work');
data.setValue(0, 1, 11);
data.setValue(1, 0, 'Eat');
data.setValue(1, 1, 2);
data.setValue(2, 0, 'Commute');
data.setValue(2, 1, 2);
data.setValue(3, 0, 'Watch TV');
data.setValue(3, 1, 2);
data.setValue(4, 0, 'Sleep');
data.setValue(4, 1, 7);
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 450, height: 300, title: 'My Daily Activities'});
Has anybody else come across a similar issue? I know the data is passed right and everything is received, but it just seems like Firefox is not playing nice with the iframes.
If anyone has any suggestions or thoughts, that would be great
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我只在 FFox 上遇到同样的问题。
我解决了将所有内容包装在一个函数中并使用一个小的 setTimeout 调用它
I had the same problem on FFox only.
I solved wrapping everything in a function and calling it with a small setTimeout
就在我读到你的帖子后几个小时,问题只出现在 FF 中,我找到了解决方案。在页面上导入 JQuery,
然后添加一个标记
,其中 drawVisualization() 是绘图函数。
它的作用就像魅力...
ps 谢谢你注意到 FF 是问题所在
Just few hours after I read your post that the problem is only in FF i found the solution. Import JQuery on your page
then add a tag
where drawVisualization() is the drawing function.
It works like charm...
p.s. thank you for noticing that FF was the problem
上周我在 Firefox 上遇到了同样的问题,这两个答案的组合对我来说也很好。不同之处在于我使用 $.load 而不是 iframe,所以我当然不需要在 AJAX 获取的 pgae 中包含 jQuery。
在 chrome 中,以下内容适用于 AJAX 页面:
然而,在 Firefox 中,这不起作用,所以我只是使用:
这在 Chrome 22 和 Firefox 16.0.1 中都对我有用
I had the same Issue with Firefox last week and a combination of both answers worked for me just fine as well. A difference is that I'm using $.load instead of an iframe, so there is no need for me to include jQuery in the pgae fetched by AJAX of course.
In chrome the following worked on the AJAX page:
In Firefox this didn't work however, so I simply used:
Which worked for me in both Chrome 22 and Firefox 16.0.1