【发布时间】:2016-06-29 01:16:28
【问题描述】:
我正在尝试创建一个仪表板来表示我在谷歌电子表格中的一些数据,并且我尽可能地遵循了谷歌图表指南(我不是程序员)。我想出了下面不工作的脚本,我需要一些帮助来让它工作。
这是我的电子表格的链接: https://docs.google.com/spreadsheets/d/1L2wjSj0IYSrA-dwYYly6rjmtw_zMCB6l7FB5B-rcvZc/edit#gid=1303777890
我试图显示为柱形图的数据位于 Sheet2 (Data2) 列 D 和 E(突出显示)中,我将该范围添加到 url 查询“range=D:E”
我想出的代码如下。我只是想让它显示图表。任何帮助表示赞赏。
enter code here<html>
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawSheetName() {
var queryString = encodeURIComponent('SELECT D, E');
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/1L2wjSj0IYSrA-dwYYly6rjmtw_zMCB6l7FB5B-rcvZc/edit#gid=1303777890range=D:E');
query.send(handleSampleDataQueryResponse);
}
function handleSampleDataQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, { height: 400 });
}
}
【问题讨论】:
标签: google-apps-script google-sheets