The task
I'm building a smaller scale website with limited content that needs to be 
regularly updated. Most of the content is lists that currently live in 
spreadsheets, so I had the bright idea to keep the existing Gdocs 
spreadsheets and use gviz to import the data, which JS could then properly 
format and drop in to the DOM. Whenever content needs to be updated then 
anyone can edit the spreadsheet and viola, the site is automagically 
updated.

The code
        var rq = function(){
            var query = new google.visualization.Query(sheet);
            query.send(handleData);
        };
        google.setOnLoadCallback(rq);
        var handleData = function(response) {
            if (response.isError()) {
                alert('Error in query: ' + response.getMessage() + ' ' + 
response.getDetailedMessage());
                return;
            }
            var rows = response.getDataTable().toJSON();
            console.log(rows);
Pretty straight forward gviz query, but the content was not importing 
properly. ALL of the row data was getting concatenated in to the "cols" 
labels. I spent several hours researching to no avail.

The solution
Gviz is, of course, intended for creating charts and visualizations. It 
expects to see numeric content for plotting. Without at least one column of 
numbers in my spreadsheet it didn't know how to parse the spreadsheet data. 
The solution was simple. Adding a column of rowIDs (although it could be 
any column of numbers, dates, amounts, etc.) gave gviz the context it 
needed to properly parse the data into cols and rows.

-- 
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.

Reply via email to