function doGet(e) { // Load the spreadsheet that contains the sheet of student data you want to chart, with the first column containing student email address. // Replace the spreadsheet KEY in quotes with yours var ss = SpreadsheetApp.openById("0AjdG0Zk4rfrwdDNWVE5RcDRUMWRud0lDYW81ZldtTHc"); // Load the sheet that contains the data by name. Change the value in quotes to reflect your setup. var sheet = ss.getSheetByName("Grades"); // Get the range of cells that store the Student ID lookup table, including the student email address as the first column. This range name is defined within the spreadsheet in the Data-> dropdown. // Define this randge to include all students and data columns you hope to chart, leaving the row of column headers just above the selection. // In this example, the range "studentlookup" is defined as A2:I6 var studentLookuprange = ss.getRangeByName("studentlookup"); // Set the number of the column that contains the first data column you want to include on the chart. // This assumes the first column in the spreadsheet is 1 (not zero). Change to reflect your setup. var firstdatacolumn = 5; // Set some of the properties of your bar chart // Change the values in quotes to reflect your setup. Colors can also be six character web colors starting with # ex) #00FFFF var horizontal = "Competencies"; var vertical = "% Mastery"; var title = "Progress Towards Mastery"; var barcolor = "green"; var min = 0; var max = 100; var width = 800; var height = 400; // For every row of student data, generate an object that contains all information from that row. var studentObjects = getRowsData(sheet, studentLookuprange); // Prepare an array to be filled with numerical data for use in the chart var columnData = new Array(); // Load the labels from the header row of the spreadsheet var headerLabels = getHeaderLabels(sheet, studentLookuprange); // Load the email address of the currently logged-in user on the Site var loggedInEmail = Session.getActiveUser().getEmail(); // Prepare various variables for use as loop indeces var i = 0; var j = 0; var n = 0; if (loggedInEmail != "") { // Get the total number of students loaded from the defined range var k = studentObjects.length; // Load the currently logged in student's data // Note that i is a flag, which goes from 0 to 1 when a row's email matches the logged in user. for (;(i==0)&&(j 0) { keys.push(key); } } return keys; } // Normalizes a string, by removing all alphanumeric characters and using mixed case // to separate words. The output will always start with a lower case letter. // This function is designed to produce JavaScript object property names. // Arguments: // - header: string to normalize // Examples: // "First Name" -> "firstName" // "Market Cap (millions) -> "marketCapMillions // "1 number at the beginning is ignored" -> "numberAtTheBeginningIsIgnored" function normalizeHeader(header) { var key = ""; var upperCase = false; for (var i = 0; i < header.length; ++i) { var letter = header[i]; if (letter == " " && key.length > 0) { upperCase = true; continue; } if (!isAlnum(letter)) { continue; } if (key.length == 0 && isDigit(letter)) { continue; // first character must be a letter } if (upperCase) { upperCase = false; key += letter.toUpperCase(); } else { key += letter.toLowerCase(); } } return key; } // Returns true if the cell where cellData was read from is empty. // Arguments: // - cellData: string function isCellEmpty(cellData) { return typeof(cellData) == "string" && cellData == ""; } // Returns true if the character char is alphabetical, false otherwise. function isAlnum(char) { return char >= 'A' && char <= 'Z' || char >= 'a' && char <= 'z' || isDigit(char); } // Returns true if the character char is a digit, false otherwise. function isDigit(char) { return char >= '0' && char <= '9'; } // Given a JavaScript 2d Array, this function returns the transposed table. // Arguments: // - data: JavaScript 2d Array // Returns a JavaScript 2d Array // Example: arrayTranspose([[1,2,3],[4,5,6]]) returns [[1,4],[2,5],[3,6]]. function arrayTranspose(data) { if (data.length == 0 || data[0].length == 0) { return null; } var ret = []; for (var i = 0; i < data[0].length; ++i) { ret.push([]); } for (var i = 0; i < data.length; ++i) { for (var j = 0; j < data[i].length; ++j) { ret[j][i] = data[i][j]; } } return ret; }