Oops, I realized there may be some issues with using a persistent dataView 
object, so here is the revised listener:

/*  assumes:
 *    chart is the visualization chart object
 *    options is an object with option settings to draw the chart with
 *    data is the dataTable object
 *    hideCols is an array of columns that should be hidden (can start 
empty)
 *  this event listener detects clicks on the legend and redraws the chart 
with the
 *  clicked-on column hidden
 */
google.visualization.events.addListener(chart, 'select', function () {
    // if row is undefined, we clicked on the legend
    if (typeof chart.getSelection()[0]["row"] === 'undefined') {
        hideCols.push(chart.getSelection()[0]["column"]);
        var view = new google.visualization.DataView(data);
        view.hideColumns(hideCols);
        chart.draw(view, options);
    }
});

-- 
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/-/6N96av5rdP0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to