Thanks for your help.
The example works fine now. Here is the updated version: 
http://jsfiddle.net/Zrxyy/8/
Anish

On Friday, July 18, 2014 5:47:24 PM UTC+5:30, Andrew Gallant wrote:
>
> The "select" event is now available through the ChartWrapper, so you don't 
> have to go through creating a "ready" event handler just to create a 
> "select" event handler.  The reason your previous code didn't work is 
> because you created the "ready" event handler after drawing the dashboard, 
> so it is likely that the chart fired its ready event before you created the 
> handler.  The solution is to create event handlers (in particular, "ready" 
> event handlers, other events are less sensitive) before drawing the chart 
> they are attached to.
>
> After fixing that, your event handler uses the wrong variable for the 
> chart, so you have to change chart to scatterchart.  Also, you have to 
> access the wrapper's internal chart object to get the selection via the 
> #getChart method:
>
> var selection = scatterchart.getChart().getSelection();
>
> Since you are working with a Dashboard and control that could filter your 
> data, you can't use the indicies from the selection to reference the base 
> DataTable, as the data may be filtered.  Reference the data used by the 
> chart instead, via the #getDataTable method:
>
> var dt = scatterchart.getDataTable();
> for (var i = 0; i < selection.length; i++) {
>     var item = selection[i];
>     if (item.row !== null) {
>         var data1 = dt.getFormattedValue(item.row, 0);
>         var data2 = dt.getFormattedValue(item.row, 1);
>         alert(data1 + ' ' + data2);
>     }
> }
>
> see working example here: http://jsfiddle.net/asgallant/Zrxyy/5/
>
> On Friday, July 18, 2014 6:57:06 AM UTC-4, Anish Benjamin wrote:
>>
>> Thank you for your help, but the problem happens when you use the event 
>> handler with the chartWrapper. The event handler isn't called when the 
>> selected event happens. I found out one mistake I was making, and fixed it, 
>> *but 
>> it still doesn't work*. See the code here: 
>> http://jsfiddle.net/anishbenji/Zrxyy/2/. 
>> first a listener has to created to check to see if the chart is ready, 
>> then the callback function should create the event handler that creates a 
>> listener for the required event. See more documentation here: 
>> https://google-developers.appspot.com/chart/interactive/docs/reference#chartwrapperobject
>> Anish
>>
>> On Thursday, July 17, 2014 7:05:49 PM UTC+5:30, [email protected] 
>> wrote:
>>>
>>> Hopefully i can actually help someone. Change your method to the below:
>>>
>>> function myClickHandler(){
>>>     var selection = chart.getSelection();
>>>     for (var i = 0; i < selection.length; i++) {
>>>         var item = selection[i];
>>>         if (item.row != null) {
>>>         var data1 = data.getFormattedValue(item.row,0);
>>>         var data2 = data.getFormattedValue(item.row, 2);
>>>         alert(data1 + ' ' + data2);
>>>               
>>>         }
>>>         
>>>     }
>>>     
>>> }
>>>
>>>
>>> On Thursday, 17 July 2014 14:00:57 UTC+1, Anish Benjamin wrote:
>>>>
>>>> I've gotten the scatter chart example in the visualization to work with 
>>>> getSelection: http://jsfiddle.net/anishbenji/gCVE8/
>>>> but my example with the slider doesn't work with getSelection.
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to