Thanks alot, that worked like a charm.
Thanks.
On Friday, December 7, 2012 12:19:22 PM UTC+5:30, asgallant wrote:
>
> Pass the chart to the selectHandler function; it should be this:
>
> google.visualization.events.addListener(baselinechart[classname],
> 'select', function () {
> selectHandler(baselinechart[classname]);
> });
>
> If that is part of a loop (or other structure in which the value of
> "classname" can change), then you would want to use a closure to lock the
> value of classname to the handler at the time when the event handler is
> created. It would look like this:
>
> google.visualization.events.addListener(baselinechart[classname],
> 'select', (function (x) {
> return function () {
> selectHandler(baselinechart[x]);
> }
> })(classname));
>
> which locks the value of "classname" to the internal variable "x" at the
> time the event handler is created. Otherwise, the event handler would use
> whatever the current value of classname is when the event fires.
>
> On Thursday, December 6, 2012 11:58:11 PM UTC-5, Shivs wrote:
>>
>> Somehow that did not work for me.
>> So i have an array of charts:-
>> google.visualization.events.addListener(baselinechart[classname],
>> 'select',function(){
>> selectHandler(baselinechart[classname].getSelection());
>> });
>>
>> The above resulted in an empty array being passed to the function.
>>
>> What am i missing?
>>
>>
>> On Friday, December 7, 2012 12:41:30 AM UTC+5:30, asgallant wrote:
>>>
>>> The events don't pass any information about which chart fired the event,
>>> so there is nothing in the API that can do this, but there is a way around
>>> it:
>>>
>>> function selectHandler (chart) {
>>> var selection = chart.getSelection();
>>> }
>>> google.visualization.events.addListener(myChart, 'select', function () {
>>> selectHandler(myChart);
>>> });
>>> google.visualization.events.addListener(myOtherChart, 'select',
>>> function () {
>>> selectHandler(myOtherChart);
>>> });
>>>
>>> On Thursday, December 6, 2012 5:44:42 AM UTC-5, Shivs wrote:
>>>>
>>>> Hey
>>>>
>>>> Wanted to know if it is possible to have same select event handler for
>>>> multiple charts.
>>>> If so, how can one determine which chart was clicked (for calling
>>>> function getSelection())?
>>>>
>>>> Thanks
>>>>
>>>
--
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/-/4GOmTGHSNjwJ.
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.