Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Google Apps Script to generate ChartFusion datasource xml from a Google Spreadsheet
function setUp() {
ScriptProperties.setProperty('active', SpreadsheetApp.getActiveSpreadsheet().getId());
var svc = ScriptApp.getService();
if (!svc.isEnabled()) {
// it's not enabled, and should be
function doGet(e){
// uses 2d array library
var t = HtmlService.createTemplateFromFile("oomfo template"); =;
//var id ="q1";
var doc = SpreadsheetApp.openById(ScriptProperties.getProperty('active'));
var sheet = doc.getSheetByName("ALL");
var data = sheet.getRange(2, 3, sheet.getLastRow(), 2).getValues();
var filtered = ArrayLib.filterByText(data, 0,;
counts = {};
for (i in filtered){
if (counts[filtered[i][1]] == undefined){ // see if tweet is in our object store
counts[filtered[i][1]] = 0; // if not add it using the tweet text as key
t.counts = counts;
//return t.evaluate();
return ContentService.createTextOutput(t.evaluate().getContent())
<chart caption="Voting Response for <?= id ?>" yaxisname="Votes" xaxisname="Option" showvalues="0" animation="1" stack100percent="0" themename="Default">
<set label="A" value="<?= counts.A || 0 ?>"/>
<set label="B" value="<?= counts.B || 0 ?>"/>
<set label="C" value="<?= counts.C || 0 ?>"/>
<set label="D" value="<?= counts.D || 0 ?>"/>
<set label="E" value="<?= counts.E || 0 ?>"/>
<chart themename="Default"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.