每次我尝试从数据中加载图表时,都会显示“意外错误”。
我已经从 1480 行的数据表中加载了数据。通过谷歌菜单添加它的图表完美无缺。
当我通过脚本添加它时,它失败并出现以下错误:“遇到错误:发生意外错误”
function doGet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var lastrow = (sheet.getLastRow());
// Get the range of cells that store mining data.
var mining = ss.getRange("A2:H"+lastrow);
// For every row of mining data, generate a mining object.
var miningObjects = getRowsData(sheet, mining);
var dataload = Charts.newDataTable();
dataload.addColumn(Charts.ColumnType.STRING, "Date");
dataload.addColumn(Charts.ColumnType.NUMBER, "Hash");
for(var i = 0; i<miningObjects.length;i++){
var support = miningObjects[i]
//Browser.msgBox(Utilities.formatDate(support.date, "GMT-4", "yyyy-MM-dd HH:mm")+"")
dataload.addRow([Utilities.formatDate(support.date, "GMT-3", "yyyy-MM-dd HH:mm")+"", support.hash])
}
dataload.build();
var lineChart = Charts.newLineChart()
.build();
var control = Charts.newStringFilter()
.setFilterColumnLabel("Date")
.build();
var dashboard = Charts.newDashboardPanel()
.setDataTable(dataload)
.bind(control, lineChart)
.build();
var uiApp = UiApp.createApplication();
dashboard.add(uiApp.createVerticalPanel()
.add(uiApp.createHorizontalPanel()
.add(lineChart)
.setSpacing(10)));
uiApp.add(dashboard);
ss.show(uiApp);
}
原始电子表格在这里。出于测试目的,我只使用前两行。
https://docs.google.com/spreadsheet/ccc?key=0AsNSSsm28wUfdFFKRU5SaFdKWkhNVWw0dTlPbXJvOVE&usp=sharing