First, your query URL needs to be adjusted slightly: "https://docs.google.com/spreadsheets/d/16HsbYp-W-keFce7CvPBVPPdxSFR_eSoQ5-P4Y791xjk/ gviz/tq". That will return the data in the appropriate format. To get the data from cell f2, you have to make a second query to this URL: "https://docs.google.com/spreadsheets/d/16HsbYp-W-keFce7CvPBVPPdxSFR_eSoQ5-P4Y791xjk/gviz/tq?range=f2". Here's an example: http://jsfiddle.net/asgallant/npanbvo6/
On Tuesday, September 2, 2014 11:26:23 PM UTC-4, Lance Greenwood wrote: > > Hi all, > > OK so I'm out of my depth and trying to do something I'm sure is really > easy if you know what you're doing - so I'm hoping someone can help me > out. This is a 'love project' for my daughters school. > > Basically I'm setting up a Google Spreadsheet where they can enter the > fortnightly School House points and have a chart automatically updated on > the school website. I've got it all working pretty much how I want it > except for 1 little thing.... I'd like to have the Title of the Chart (on > the web page) updated based on what they enter in the spreadsheet > (basically so they can indicate the date of the results). > > The "Title" is here: > > https://docs.google.com/spreadsheets/d/16HsbYp-W-keFce7CvPBVPPdxSFR_eSoQ5-P4Y791xjk/pubhtml?gid=0&single=true&range=F2 > > The Chart is embedded in a Weebly website using this code: > > <script type="text/javascript" src="https://www.google.com/jsapi"></script > > > <script type="text/javascript"> > google.load("visualization", '1', { > packages: ['corechart'] > }); > google.setOnLoadCallback(drawChart); > var ChartSource = ' > https://docs.google.com/spreadsheets/d/16HsbYp-W-keFce7CvPBVPPdxSFR_eSoQ5-P4Y791xjk/edit?usp=sharing > '; > var ChartTitle = "How do I get this to lookup cell F2 in my Google > sheet??"; > > function drawChart() { > var query = new google.visualization.Query( > ChartSource); > query.send(handleQueryResponse); > } > function handleQueryResponse(response) { > if (response.isError()) { > alert('Error in query: ' + response.getMessage() + ' ' + > response.getDetailedMessage()); > return; > } > var options = { > backgroundColor: 'white', > chartArea: { > left: 20, > top: 20, > width: '90%', > height: '80%' > }, > title: ChartTitle, > titleTextStyle: { > fontSize: 14 > }, > width: 280, > height: 180, > bar: { > groupWidth: "68%" > }, > vAxis: { > textPosition: "none", > minValue: 0 > }, > legend: { > position: "none" > }, > }; > var data = response.getDataTable(); > data.setColumnProperty(2, 'role', 'style'); > var view = new google.visualization.DataView(data); > view.setColumns([0, 1, { > calc: "stringify", > sourceColumn: 1, > type: "string", > role: "annotation" > }, > 2]); > var chart = new > google.visualization.ColumnChart(document.getElementById('columnchart')); > chart.draw(view, options); > } > </script> > <title>Data from a Spreadsheet</title> > </head> > <body> > <span id='columnchart'></span> > </body> > > > Many, many, many thanks! > > -- 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 http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/d/optout.
