How do I annotate text on the vAxis

15 views
Skip to first unread message

MinuetMan

unread,
Jul 7, 2011, 1:49:47 PM7/7/11
to Google Visualization API
I am trying to annotate my vertical axis (which is seconds) but I
could not do this... I started with:

// Create and draw the visualization.
new
google.visualization.ColumnChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
width:600, height:400,
hAxis: {title: "Year"}}
);

and added the following

// Create and draw the visualization.
new
google.visualization.ColumnChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
width:600, height:400,
hAxis: {title: "Year"},
vAxis: {title: "Seconds"}}
);

but that did not work! Any help is appreciated!

asgallant

unread,
Jul 8, 2011, 9:35:10 AM7/8/11
to google-visua...@googlegroups.com
Can you post the full code?  Adding the vAxis title works for me on the visualization playground (http://code.google.com/apis/ajax/playground/?type=visualization#column_chart).

Google-Sree Iyer

unread,
Jul 8, 2011, 10:42:42 AM7/8/11
to google-visua...@googlegroups.com
Hi
 
I took your example and added vAxis and it does not like it... Here is the code:
 
function drawVisualization() {
  // Create and populate the data table.
  var data = new google.visualization.DataTable();
  var raw_data = [['Austria', 1336060, 1538156, 1576579, 1600652, 1968113, 1901067],
                  ['Belgium', 3817614, 3968305, 4063225, 4604684, 4013653, 6792087],
                  ['Czech Republic', 974066, 928875, 1063414, 940478, 1037079, 1037327],
                  ['Finland', 1104797, 1151983, 1156441, 1167979, 1207029, 1284795],
                  ['France', 6651824, 5940129, 5714009, 6190532, 6420270, 6240921],
                  ['Germany', 15727003, 17356071, 16716049, 18542843, 19564053, 19830493]];
  
  var years = [2003, 2004, 2005, 2006, 2007, 2008];
                  
  data.addColumn('string', 'Year');
  for (var i = 0; i  < raw_data.length; ++i) {
    data.addColumn('number', raw_data[i][0]);    
  }
  
  data.addRows(years.length);

  for (var j = 0; j < years.length; ++j) {    
    data.setValue(j, 0, years[j].toString());    
  }
  for (var i = 0; i  < raw_data.length; ++i) {
    for (var j = 1; j  < raw_data[i].length; ++j) {
      data.setValue(j-1, i+1, raw_data[i][j]);    

    }
  }
  
  // Create and draw the visualization.
  new google.visualization.ColumnChart(document.getElementById('visualization')).
      draw(data,
           {title:"Yearly Coffee Consumption by Country", 
            width:600, height:400,
            hAxis: {title: "Year"},
            vAxis: (title: "What"}
      );
}
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/laJ10M7eal4J.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

asgallant

unread,
Jul 8, 2011, 12:11:24 PM7/8/11
to google-visua...@googlegroups.com
You have two syntax errors in your code.  The vAxis option needs to open with the curly braces "{" instead of the parentheses "(", and the options need a closing curly braces, like this:

     new google.visualization.ColumnChart(document.getElementById('visualization')).draw(data, {

          title:"Yearly Coffee Consumption by Country",
          width:600,
          height:400,
          hAxis: {title: "Year"},
          vAxis: {title: "What"}
     });

Google-Sree Iyer

unread,
Jul 8, 2011, 12:16:09 PM7/8/11
to google-visua...@googlegroups.com
Thanks for the prompt response... One suggestion... In the sample, leave vAxis in with "" if you cannot think of something appropriate.
 
Sree
----- Original Message -----
From: asgallant
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
Reply all
Reply to author
Forward
0 new messages