That example is for use in web pages, where you also load the loader, and setOnLoadCallback(). The example is not complete, and needs to be improved, but you can find some more complete examples here: https://developers.google.com/chart/interactive/docs/drawing_charts You'll have to substitute in the fetching of data from your spreadsheet. I hope that gives you enough clues about how to proceed.
On Sat, Jul 16, 2016 at 12:35 PM, Josh Newland <[email protected]> wrote: > I'm trying to build a chart from a google spreadsheet and embed it in > another google spreadsheet. As a starting point, I wanted to just test the > example given on this page: > https://developers.google.com/chart/interactive/docs/spreadsheets#sheet-name > > So I made a new spreadsheet, opened the script editor and pasted the > example code into it: > > function drawSheetName() { > var queryString = encodeURIComponent('SELECT A, H, O, Q, R, U LIMIT 5 > OFFSET 8'); > > var query = new google.visualization.Query( > > 'https://docs.google.com/spreadsheets/d/1XWJLkAwch5GXAt_7zOFDcg8Wm8Xv29_8PWuuW15qmAE/gviz/tq?sheet=Sheet1&headers=1&tq=' > + queryString); > query.send(handleSampleDataQueryResponse); > } > > function handleSampleDataQueryResponse(response) { > if (response.isError()) { > alert('Error in query: ' + response.getMessage() + ' ' + > response.getDetailedMessage()); > return; > } > > var data = response.getDataTable(); > var chart = new > google.visualization.ColumnChart(document.getElementById('chart_div')); > chart.draw(data, { height: 400 }); > } > > > I then created a shape in my google sheet and assigned the script > "drawSheetName" to it. Upon clicking the shape, I get the > error: ReferenceError: "google" is not defined. > > What am I doing wrong here? > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to > [email protected]. > Visit this group at > https://groups.google.com/group/google-visualization-api. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-visualization-api/96c3190b-5d27-4152-9296-fb4c602eca60%40googlegroups.com > <https://groups.google.com/d/msgid/google-visualization-api/96c3190b-5d27-4152-9296-fb4c602eca60%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> [email protected] <[email protected]> 5CC, Cambridge MA -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJO0vvEACW6UZ7q6K65z9qR6oUA%2BJgF0Lb%2BEmToXJQEN1Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
