Using Google Visualization API in Google Sites

505 views
Skip to first unread message

alwave9

unread,
Jan 11, 2012, 9:34:57 AM1/11/12
to Google Visualization API
Hi,

I am trying to use Google Visualization APIs on my Google Site web
page to query and visualize data stored in Google spreadsheets. I am
not sure what is the best way to do it: create a gadget (I am not very
familiar how to do it) or use Apps Script module and then insert the
script into the page.

When I try to use Google Visualization API (I copied some sample code
form Google Visualization Playground samples and pasted into Apps
Script Editor), I get this error:

ReferenceError: "google" is not defined. (line 3)

this the sample code

function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable(); - this is the line
3
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows(5);
data.setValue(0, 0, 'Work');
data.setValue(0, 1, 11);
data.setValue(1, 0, 'Eat');
data.setValue(1, 1, 2);
data.setValue(2, 0, 'Commute');
data.setValue(2, 1, 2);
data.setValue(3, 0, 'Watch TV');
data.setValue(3, 1, 2);
data.setValue(4, 0, 'Sleep');
data.setValue(4, 1, 7);

// Create and draw the visualization.
new
google.visualization.PieChart(document.getElementById('visualization')).
draw(data, {title:"So, how was your day?"});
}

Could you kindly help me to understand how to use Visualization APIs
in the Google Sites page? If gadgets is the only way to do it then I
will learn how to do it, but if there is another way besides the
gadget creation, please let me know. I have been able to create a
stand alone html page which loads and uses the Visualization APIs, but
Google Sites does not allow to upload html pages, and I need to
somehow insert my code into Google Site page.

Maybe there is a way to load Visualization API into apps script
editor? Unfortunately cannot find how to do it.

Thank you

Liya

ChartMan

unread,
Jan 12, 2012, 7:42:45 AM1/12/12
to google-visua...@googlegroups.com
There is a new option - 'Insert > Chart'.
It let's you select a spreadsheet and insert either a chart from within that spreadsheet or create a new chart over that sheet data.

HTH
ChartMan


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


alwave9

unread,
Jan 12, 2012, 12:23:23 PM1/12/12
to Google Visualization API
Thank you ChartMan! I am actually trying to use Visualization API to
run queries against spreadsheets, and output result as tables or
charts to web pages on my Google Site. I am looking for the simplest
way to do it. For now it looks like the only way is to create gadgets
and insert them into the Google Sites pages. Or use another host for
my pages with regular html/javascript.

Thanks,
Liya

ChartMan

unread,
Jan 12, 2012, 1:35:55 PM1/12/12
to google-visua...@googlegroups.com

Doesn't inset chart work for you?

alwave9

unread,
Jan 12, 2012, 10:08:17 PM1/12/12
to Google Visualization API
I tried to insert a chart and it is quite nice. Though I can't find a
way to use a query as the data source for the chart. I also need to
combine data from 2-3 different spreadsheets in my query and output.
Join them in SQL words. Thanks

On Jan 12, 1:35 pm, ChartMan <chart...@google.com> wrote:
> Doesn't inset chart work for you?

ChartMan

unread,
Jan 13, 2012, 4:21:43 AM1/13/12
to google-visua...@googlegroups.com
Try doing all the heavy lifting in a dedicated spreadsheet and then use this spreadsheet as the data source
for your charts in sites. 

alwave9

unread,
Jan 14, 2012, 11:48:01 PM1/14/12
to Google Visualization API
Thank you ChartMan! I am just starting to work with Google apps and
sites and not very familiar with all the options. I'll be setting
scripts and triggers in my spreadsheets.
Reply all
Reply to author
Forward
0 new messages