Octavient
Octavient

Reputation: 603

Google Visualization Pie Chart onclick event not firing in IE8

I'm using the Google Visualization API to draw a pie chart with some data.

I'm also adding an onclick event, which works perfectly in Chrome. But the event does seem to be firing at all in IE8. No error--it just doesn't fire at all.

The chart renders perfectly in all browsers--but the onclick event is not working in IE8 (and possibly other versions of IE--haven't yet tested).

Any ideas?

var dataTable = new google.visualization.DataTable();
    dataTable.addColumn('string');
    dataTable.addColumn('number');
    $.each(obj_json_data,function(){
        dataTable.addRow([this.Name,this.Number]);
    });

    var options = {cht:  'p3', chs: '600x225', labels:'name', legend:'none',
                   chds:'0,160', enableEvents:true, chdls:'000000,14'};

    var chart = new  google.visualization.ImageChart(document.getElementById('chart_container'));
    chart.draw(dataTable, options);

    // Assign  event  handler
    google.visualization.events.addListener(chart, 'onclick', mouseEventHandler);

function mouseEventHandler(event) {
    alert('You just clicked ' + event.region);
}

Upvotes: 0

Views: 1332

Answers (2)

Hiroki_ARK
Hiroki_ARK

Reputation: 11

It's not 'onclick', it's 'click' event

Upvotes: 0

In line: google.visualization.events.addListener(chart, 'onclick', mouseEventHandler);

Try pointing the listener to the 'select' event instead of the 'onclick' event.

Upvotes: 0

Related Questions