google visualization-Click event

Chart Wrappers are not chart objects and do not have a click event. In fact, Pie Charts also do not have a click event, only select.

If you read the documentation it says to:

  1. Create a ready event for the wrapper
  2. Have the ready event trigger a select event for the chart in the wrapper

Here is the example they give:

var wrapper;
function drawVisualization() {

  // Draw a column chart
  wrapper = new google.visualization.ChartWrapper({
    chartType: 'ColumnChart',
    dataTable: [['Germany', 'USA', 'Brazil', 'Canada', 'France', 'RU'],
                [700, 300, 400, 500, 600, 800]],
    options: {'title': 'Countries'},
    containerId: 'visualization'

  // Never called., 'onmouseover', uselessHandler);

  // Must wait for the ready event in order to
  // request the chart and subscribe to 'onmouseover'., 'ready', onReady);


  // Never called
  function uselessHandler() {
    alert("I am never called!");

  function onReady() {, 'onmouseover', usefulHandler);

  // Called
  function usefulHandler() {
    alert("Mouseover event!");

So in your case you will need to change this section:, 'ready', function() {
       // grab a few details before redirecting

      alert(data.getValue(chart.getSelection()[0].row, 0));
       //location.href="" + row + '&col=" + col + "&year=" + year;

To something like this:, "ready', function() {
       // grab a few details before redirecting, 'select', function() {
          chartObject = chart.getChart();
          alert(data.getValue(chartObject.getSelection()[0].row, 0));

       //location.href="" + row + '&col=" + col + "&year=" + year;

Leave a Comment