So, I have a number of charts on the same page, and I want to handle their "ready" event with a generic handler.
Say I have an array of charts called charts. I want to do something like this (except the following method doesn't work, but I hope it gets the point across):
for (var i = 0; i < charts.length; i++) {
google.visualization.events.addListener(charts[i], "ready", function () {
charts[i].setSelection([{}]); // Here I want to reference the chart object that fired this event. Doing it like this does not work.
});
}
It would be really nice if charts passed themselves along as a parameter to the handler, but as far as I can read out of the documentation, this is not the case.
Basically, I want the equivalent of using $(this) inside a jQuery event handler.
Is this possible?
Thanks