The easiest way is to set the "forceIFrame" option to false and then
(within a 'ready' event listener for the chart) assign a click event
handler to the "svg" tag inside the chart's div:
google.visualization.events.addListener(chart, 'ready', function() {
document.getElementById('chart_div').getElementsByTagName('svg')[0].
onclick = function() {
alert('foo');
};
});
On Friday, June 15, 2012 3:09:04 PM UTC-4, novito wrote:
>
> How can I catch a click event in the whole chart and not just on elements
> of the chart?
>
> Right now I have this:
>
> google.visualization.events.addListener(chart,'select',callbackFunction);
>
> But that just adds a listener for the items/elements of the charts. If,
> for example, in a column chart I click not on a column but on the xAxis, no
> event is triggered. I tried adding an onclick on the container of the
> chart, but that just will trigger if you click on the outter part of the
> chart.
>
> So my question is: How can I add a listener for the whole chart? Not just
> the elements on it.
>
--
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/-/OY-h5dYmuuEJ.
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.