Pulling data from a spread sheet in my google drive

180 views
Skip to first unread message

fcdphepide...@gmail.com

unread,
Oct 28, 2013, 5:43:56 PM10/28/13
to google-visua...@googlegroups.com
Greetings Everyone,

I am not a programmer by training, but I like to think that I am quasi savvy in augmenting code that has already been written. Google has made this exponentially easier with their Google Charts tool. I have successfully created a chart that works in the Google Code Playground by adding the data directly into the chart code. However, I would like to pull this information from a spread sheet I have in my Google Drive.

I visited the tutorial below: 


This specific step was not able to be followed: From the spreadsheet toolbar, click 'Insert' and choose 'Gadget'. Choose an existing gadget or select 'Custom' as the gadget type, enter the URL of your gadget XML specification and click 'Add'. You can choose a visualization gadget, if you want your visualization to live in the spreadsheet; otherwise, you can choose any gadget if you just need to get a URL to pass to an external visualization .

There is no Gadget from insert any longer.

I published the spreadsheet as a website and used that URL in the code. Any assistance with what precisely I am doing wrong would be greatly appreciated.

It was not helpful.

I am trying to get data from my Google Spreadsheet to fill in my Motion Chart from the Google Charts tool.

asgallant

unread,
Oct 28, 2013, 6:39:36 PM10/28/13
to google-visua...@googlegroups.com
You don't need to use the "gadget" method to get the spreadsheet URL.  Look in the URL of your spreadsheet: there is a "key" parameter "key=<string of characters/numbers>", for example, in this url: "https://docs.google.com/spreadsheet/ccc?key=0AiFfbdok-kQKcENRYmV0ZC1DcHRHWHh4UUlHN1ZGSVE#gid=0", the key is "0AiFfbdok-kQKcENRYmV0ZC1DcHRHWHh4UUlHN1ZGSVE".  The URL of the data source is then "https://docs.google.com/spreadsheet/tq?key=<your key>" ("https://docs.google.com/spreadsheet/tq?key=0AiFfbdok-kQKcENRYmV0ZC1DcHRHWHh4UUlHN1ZGSVE" in the example).  Basically, the only significant difference between the two URL's is that one has "ccc" and the other has "tq" as the last parameter in the path.

Fresno County Epidemiologists

unread,
Oct 28, 2013, 6:54:49 PM10/28/13
to google-visua...@googlegroups.com
Greetings,

I was able to pull that information out, yet the code still did not work.


--
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/-hrK44Bxb38/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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

asgallant

unread,
Oct 28, 2013, 7:05:49 PM10/28/13
to google-visua...@googlegroups.com
If you got the spreadsheet URL correct, then there is something else wrong in your code.  If you post the code you are using, I can take a look and maybe see what the problem is.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.

Fresno County Epidemiologists

unread,
Oct 29, 2013, 11:52:34 AM10/29/13
to google-visua...@googlegroups.com
Greetings,

So I got it working this morning then something occured and I cannot get it to work again. Please take a look at my code.

Thanks,

function drawVisualization({
  // To see the data that this visualization uses, browse to
  // http://spreadsheets.google.com/ccc?key=0AgvlMLEoZV9hdFAzNjhSNUxoMmc4N0poZ0hNV0RwT2c
  var query new google.visualization.Query(
      'http://spreadsheets.google.com/tq?key=0AgvlMLEoZV9hdFAzNjhSNUxoMmc4N0poZ0hNV0RwT2c&single=true&gid=0&output=html');

  // Send the query with a callback function.
  query.send(handleQueryResponse);
}

function handleQueryResponse(response{
  if (response.isError(){
    alert('Error in query: ' response.getMessage(' ' response.getDetailedMessage());
    return;
  }

  var data response.getDataTable();
  visualization new google.visualization.MotionChart(document.getElementById('visualization'));
  visualization.draw(data{'width'800'height':400});


To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

asgallant

unread,
Oct 29, 2013, 12:06:06 PM10/29/13
to google-visua...@googlegroups.com
I made a jsfiddle based on that code, and it works: http://jsfiddle.net/asgallant/Htmf7/
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.

Fresno County Epidemiologists

unread,
Oct 29, 2013, 1:24:25 PM10/29/13
to google-visua...@googlegroups.com
You sir are a life saver. I appreciate your assistance with this code incompetent epidemiologist.

Cheers,


To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

asgallant

unread,
Oct 29, 2013, 1:30:31 PM10/29/13
to google-visua...@googlegroups.com
You're welcome, from an epidemiologically-challenged coder.

Jon Orwant

unread,
Nov 6, 2013, 3:03:13 PM11/6/13
to google-visua...@googlegroups.com
asgallant is correct (as always) that gadgets aren't necessary.  I've updated the Google Charts documentation at

Jon


--
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.
Reply all
Reply to author
Forward
0 new messages