gpt4 book ai didi

javascript - 无法在 Google Visualization API 图表中加载工作表

转载 作者:行者123 更新时间:2023-11-27 23:51:58 24 4
gpt4 key购买 nike

我正在尝试使用 Google 图表添加到我公司的网站,但在连接工作表时遇到问题。我从基础知识开始,尝试在教程中重新创建饼图示例,但让图表从工作表加载数据,而不是在代码中创建表格。我显然做错了什么。当我查看控制台时,它显示:

解析“sandbox”属性时出错:“allow-popups-to-escape-sandbox”是无效的沙箱标志。

我是否没有正确设置某些内容?

我知道这可能是一个非常基本的问题,但我才刚刚开始,希望得到帮助。这是我的代码:

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

google.load('visualization', '1.0', {'packages':['corechart']});

google.setOnLoadCallback(drawChart);

// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.

function drawChart() {
var query = new google.visualization.Query('http://docs.google.com/spreadsheets/d/1WvVr748_MgWa0goyfwlMB2AX_AYtfvXnsLP8N1kyaek');
query.send(handleQueryResponse);
}

function handleQueryResponse(response) {
var data = response.getDataTable();

}


var options = {'title':'How Many Donuts I Ate',
'width':400,
'height':300};

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

</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>

最佳答案

您应该在 drawChart() 中包含整个“绘制图表过程”

<script type="text/javascript">

google.load('visualization', '1.0', {'packages':['corechart']});

google.setOnLoadCallback(drawChart);

// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.

function drawChart() {
var query = new google.visualization.Query('http://docs.google.com/spreadsheets/d/1WvVr748_MgWa0goyfwlMB2AX_AYtfvXnsLP8N1kyaek');
query.send(handleQueryResponse);


function handleQueryResponse(response) {
var data = response.getDataTable();
}


var options = {'title':'How Many Donuts I Ate',
'width':400,
'height':300};

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

关于javascript - 无法在 Google Visualization API 图表中加载工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32622110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com