我希望我的网页在google网站上显示图表,我使用的数据源是google电子表格。我测试我的代码,它在JSFiddle中运行良好。但是当我将我的代码复制到Google Apps脚本时,它会因ReferenceError而失败:" google"没有定义。我不知道,我不知道应该添加什么,使用google.visualization API,也许Google Apps脚本不支持google.visualization API?我只是添加函数doGet(),你可以看到我的代码:
function doGet() {
google.setOnLoadCallback(drawChart);
function drawChart() {
var query = new google.visualization.Query(
'https://docs.google.com/a/valeo.com/spreadsheets/d/1wMku94s8LsbwPdoaVsJNL5IPdKVUdv8ZC_jgo2suV4Q/edit#gid=1287756093');
query.setQuery('select A, C');
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
var options = {
title: 'MS Project Licence From 2014',
hAxis: {title: 'Month',titleTextStyle: {color: 'red'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById('visualization'));
chart.draw(data, options);
}
}
赞赏任何建议