Drawing a Column Chart using Google Spreadsheets as my Datasource !!GRAPH OUTPUT WON'T SHOW UP!!

58 views
Skip to first unread message

igba...@colorado.edu

unread,
Jun 8, 2016, 3:59:22 PM6/8/16
to Google Visualization API
https://developers.google.com/chart/interactive/docs/spreadsheets#embedding-achart-in-a-spreadsheet

Hey guys, I checked my JSON file and no errors show up and I can't seem to find an error in my code, but my chart isn't showing up.

Does anyone have a clue as to why it's not showing up? 
Screen Shot 2016-06-08 at 3.49.05 PM.png

Daniel LaLiberte

unread,
Jun 8, 2016, 4:15:07 PM6/8/16
to Google Visualization API
We won't be able to tell from your code that does the fetching.  All depends on what's in your spreadsheet.  Could you point us at that?  I don't want to type in the googlygoop url.  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 google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
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/c8312698-14ab-4a23-be1a-215fc6cfcfb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Igor Banaszuk

unread,
Jun 8, 2016, 9:13:45 PM6/8/16
to google-visua...@googlegroups.com
Here's a screenshot of the spreadsheet. 

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/yng8AR-BJ9A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
Screen Shot 2016-06-08 at 9.08.35 PM.png

Igor Banaszuk

unread,
Jun 9, 2016, 9:41:29 AM6/9/16
to google-visua...@googlegroups.com
And this is the JSON.txt file

/*O_o*/
google.visualization.Query.setResponse({"version":"0.6","reqId":"0","status":"ok","sig":"346981663","table":{"cols":[{"id":"A","label":"Year","type":"string"},{"id":"B","label":"2011","type":"number","pattern":"\u0022$\u0022#,##0"},{"id":"C","label":"2012","type":"number","pattern":"\u0022$\u0022#,##0"},{"id":"D","label":"2013","type":"number","pattern":"\u0022$\u0022#,##0"},{"id":"E","label":"2014","type":"number","pattern":"\u0022$\u0022#,##0"},{"id":"F","label":"2015","type":"number","pattern":"\u0022$\u0022#,##0"}],"rows":[{"c":[{"v":"Total Assets"},{"v":16000.0,"f":"$16,000"},{"v":54000.0,"f":"$54,000"},{"v":200000.0,"f":"$200,000"},{"v":500000.0,"f":"$500,000"},{"v":650000.0,"f":"$650,000"}]}]}});

Daniel LaLiberte

unread,
Jun 9, 2016, 11:53:20 AM6/9/16
to Google Visualization API
Google Charts requires all data to be a sequence of rows where the cells in one column all have the same type.  Your data appears to be a transpose of that, where you want the first row to be years, the second row to be amounts.

You could either transpose your data in your spreadsheet first, or perhaps the pivot operation in Query will do what you want:  https://developers.google.com/chart/interactive/docs/querylanguage#pivot


For more options, visit https://groups.google.com/d/optout.

Igor Banaszuk

unread,
Jun 9, 2016, 2:04:05 PM6/9/16
to google-visua...@googlegroups.com
Ok, I did that and now I believe my JSON is correct. Except I believe there shouldn't be quotes around table, rows, or cols? My graph still isn't showing up :(



/*O_o*/
google.visualization.Query.setResponse({"version":"0.6","reqId":"0","status":"ok","sig":"1737770902","table":{"cols":[{"id":"A","label":"Year","type":"number","pattern":"General"},{"id":"B","label":"totalAssets","type":"number","pattern":"General"}],"rows":[{"c":[{"v":2010.0,"f":"2010"},{"v":54000.0,"f":"54000"}]},{"c":[{"v":2011.0,"f":"2011"},{"v":300000.0,"f":"300000"}]}]}});

Screen Shot 2016-06-09 at 2.03.24 PM.png

Daniel LaLiberte

unread,
Jun 9, 2016, 4:19:55 PM6/9/16
to Google Visualization API
Your data looks fine now.  The property names in JSON format are required to be quoted.

So next you should look in your JavaScript console to see if there is an error.  But probably before that, just show your data in a Table, so you know everything else is working.  Add 'table' to your list of packages, and draw a google.visualization.Table.


For more options, visit https://groups.google.com/d/optout.

Igor Banaszuk

unread,
Jun 9, 2016, 8:56:44 PM6/9/16
to google-visua...@googlegroups.com
So I am probably just not calling the drawGID function properly? Maybe I should try implementing drawVisualization() and use getter methods on ChartWrapper(). 

Igor Banaszuk

unread,
Jun 11, 2016, 10:55:29 AM6/11/16
to google-visua...@googlegroups.com
Here's my console error now (I sent the screenshot of the updated code also). Every time I run it adds an extra error and I also get the error, "error in query: request timed out". 
Screen Shot 2016-06-11 at 8.47.24 AM.png
Screen Shot 2016-06-11 at 9.14.02 AM.png

Daniel LaLiberte

unread,
Jun 12, 2016, 10:16:41 PM6/12/16
to Google Visualization API
Your URL for getting the spreadsheet data has some errors.  If you are using the range parameter, then you don't want to also use the query string, which is another way of selecting the data.  Check the notation carefully on this page:  https://developers.google.com/chart/interactive/docs/spreadsheets#creating-a-chart-from-a-separate-spreadsheet


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages