Here is the code I made:

 google.visualization.events.addListener(chart, 'select', function () {
         var sel = chart.getSelection();
         // if selection length is 0, we deselected an element
        if (sel.length > 0) {
            // if row is undefined, we clicked on the legend
         alert("selected item is"+sel[0].row);
            if (sel[0].row == null) {
 var col = sel[0].column;
if (columns[col] == col) {
 // grey out the legend entry
// hide the data series
 columns[col] = {
         label: data.getColumnLabel(col),
          type: data.getColumnType(col),
           calc: function () {
                   return null;
             }
  };
 series[col - 1].color = '#CCCCCC';
 
}else{    
 // show the data series
      columns[col] = col;
      series[col - 1].color = null;
 
//var view = new google.visualization.DataView(data);
             //chart.draw(view, options);
 }
var view = new google.visualization.DataView(data);
view.setColumns(columns);
chart.draw(view, options);
}
}
        
    });

The probles is sel[0].row is never null

El dimecres 2 d’abril de 2014 16:37:42 UTC+2, [email protected] va 
escriure:
>
> Hi, 
>
> I'm making and app with Google Charts API.
>
>  I don't know how to detect when a user clicks an element from the legend. 
> In other charts (like bar charts) I use getSelection() and, if the value is 
> null it means I clicked a legend item. But in pie chart it never happens, I 
> obtain the same value of the slice.
>
> Thanks in advance.
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to