Reputation: 84
Everytime i try to load a chart from the data i have it says "unexpected error".
I've loaded data from a datasheet with 1480 rows. Adding it the chart by the google menu works flawlessly.
when i add it throught script, it fails with the following error: "Error encountered: An unexpected error ocurred"
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);
}
original spreadsheet is here. for testing purposes i'm only using the first two rows.
https://docs.google.com/spreadsheet/ccc?key=0AsNSSsm28wUfdFFKRU5SaFdKWkhNVWw0dTlPbXJvOVE&usp=sharing
Upvotes: 0
Views: 185
Reputation: 5645
Seems like there is a few things going on here. Not sure if you really want the control
filter on a date. However, in the interest of just getting this working for you - you need to also add the filter control to the dashboard
. See the .add(control)
below.
dashboard.add(uiApp.createVerticalPanel()
.add(uiApp.createHorizontalPanel()
.add(control)
.add(lineChart)
.setSpacing(10)));
Upvotes: 1