Adding click event

24 views
Skip to first unread message

Antonio Bulgheroni

unread,
Sep 14, 2011, 11:30:44 AM9/14/11
to Google Visualization API
Dear all,

I would like to do some actions when users click on a chart. The
best way would be to have a click event emitted by the chart with the
corresponding listener. But I was unable to find any click event. Am I
right?

Do you know any workaround or should I submit a feature request?

Thanks for helping,
toto

asgallant

unread,
Sep 14, 2011, 12:20:39 PM9/14/11
to google-visua...@googlegroups.com
Most charts expose the "select" event, which you can hook into via event listeners: http://code.google.com/apis/chart/interactive/docs/events.htmlhttp://code.google.com/apis/ajax/playground/?type=visualization#select_event

As an example:

/*  hooks the select event of the chart
 *  assumes:
 *    chart is the chart object
 */
google.visualization.events.addListener(chart'select'function({
    alert('select event fired');
});


You can call the #getSelection method of the chart object to get the row and/or column of the DataTable entry representing the chart element selected.
Reply all
Reply to author
Forward
0 new messages