Need help with x-y graph!

55 views
Skip to first unread message

far m

unread,
May 24, 2012, 1:40:27 PM5/24/12
to google-visua...@googlegroups.com
This is really making me crazy..... 
I am trying to perform a query on a spread sheet and then display the x-y plot; very simple! 

The problem is that if the first column (column A) contains numbers both columns A  & B are shown and the there is no X-axis. However, if column A is text then, A will be x-axis and B will be y-axis which is what i want. 

How do I make column A to show up as x-axis if it contains numbers? 

Here is the code which is straight from an example:

function drawVisualization({
  // To see the data that this visualization uses, browse to
  // http://spreadsheets.google.com/ccc?key=pCQbetd-CptGXxxQIG7VFIQ
  var query new google.visualization.Query(
      'https://docs.google.com/spreadsheet/ccc?key=0AqzQGhNv6cV-dDBzZmZ2NzVGSkVVTUEwMEZPOG5YTHc');

  // Apply query language.
  query.setQuery('SELECT A,D ORDER BY D');

  // 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.LineChart(document.getElementById('visualization'));
  visualization.draw(data);
}

asgallant

unread,
May 24, 2012, 1:57:37 PM5/24/12
to google-visua...@googlegroups.com
It works just fine for me.  Are you loading the 'corechart' package or the 'linechart' package?  If not, the 'linechart' package is deprecated, so load 'corechart' instead.  See working example here: http://jsfiddle.net/asgallant/6YNNa/ 

far m

unread,
May 25, 2012, 12:42:47 AM5/25/12
to google-visua...@googlegroups.com
Thank you asgallant..... it worked just fine! I was missing the CoreChrt. 
I tried to used jsfiddle.net. I signed up. I pasted my code, but I could not get any result (same exact code with the HTML part. . I can change your code. But cannot generate one of my own! It is strange! Here is the link: http://jsfiddle.net/essonoma/9WpdT/1/ 
Thanks again. 

asgallant

unread,
May 25, 2012, 9:21:36 AM5/25/12
to google-visua...@googlegroups.com
There's a couple things you need to do to make it work:

1) Under "Choose Framework", change from "on load" to "no wrap (head)"
2) Under "Add Resources", add the API js link: http://www.google.com/jsapi?fake=.js (the link must end in ".js" or jsfiddle won't load it properly, the "fake" parameter doesn't do anything else)

far m

unread,
May 26, 2012, 1:13:51 AM5/26/12
to google-visua...@googlegroups.com
Thank you so much! It worked! Thank you!
Reply all
Reply to author
Forward
0 new messages