What we can't see from your code is exactly what you need to look at also,
which is how the mychart1 and mychart2 might be sharing the same data, or
possibly even the same container element.  If you can post a more complete
example showing this problem, that will let us provide more help.

On Tue, Jul 25, 2017 at 3:04 AM, rakesh h <[email protected]> wrote:

> I have loaded two different data pie chart in a single page.I have used
> two different selecthandler function for two pie charts to get the slice
> name.
> But when i select first pie chart slice i am getting second chart slice
> name.Whats the problem?
>
> first chart selecthandler function
>
> google.visualization.events.addListener(mychart1,'select',selectHandler1);
>       function selectHandler1() {
>         var selection1 = mychart1.getSelection();
>         var message = '';
>         for (var i = 0; i < selection1.length; i++) {
>           var item = selection1[i];
>           if (item.row != null && item.column != null) {
>             var str1 = data.getFormattedValue(item.row, item.column);
>             message += '{row:' + item.row + ',column:' + item.column + '}
> = ' + str1 + '\n';
>           }
>           else if (item.row != null) {
>             var str1 = data.getFormattedValue(item.row, 0);
>             message += '{row:' + item.row + ', column:none}; value (col 0)
> = ' + str1 + '\n';
>           }
>           else if (item.column != null) {
>             var str1 = data.getFormattedValue(0, item.column);
>             message += '{row:none, column:' + item.column + '}; value (row
> 0) = ' + str1 + '\n';
>           }
>         }
>         if (message == '') {
>           message = 'nothing';
>         }
>               alert(str1);
>       }
>
> second chart selecthandler function
>
> google.visualization.events.addListener(mychart2,'select',selectHandler2);
>       function selectHandler2() {
>         var selection2 = mychart2.getSelection();
>         var message = '';
>         for (var i = 0; i < selection2.length; i++) {
>           var item = selection2[i];
>           if (item.row != null && item.column != null) {
>             var str2 = data.getFormattedValue(item.row, item.column);
>             message += '{row:' + item.row + ',column:' + item.column + '}
> = ' + str2 + '\n';
>           }
>           else if (item.row != null) {
>             var str2 = data.getFormattedValue(item.row, 0);
>             message += '{row:' + item.row + ', column:none}; value (col 0)
> = ' + str2 + '\n';
>           }
>           else if (item.column != null) {
>             var str2 = data.getFormattedValue(0, item.column);
>             message += '{row:none, column:' + item.column + '}; value (row
> 0) = ' + str2 + '\n';
>           }
>         }
>         if (message == '') {
>           message = 'nothing';
>         }
>               alert(str2);
>       }
>
> --
> 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 google-visualization-api@
> googlegroups.com.
> Visit this group at https://groups.google.com/
> group/google-visualization-api.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-visualization-api/6fba1dd7-00b8-4e85-bbcc-
> ff60a173e170%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/6fba1dd7-00b8-4e85-bbcc-ff60a173e170%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
[email protected] <[email protected]>   5CC, Cambridge MA

-- 
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJMV4YSionyDqaHCNE_i%2BM-tvWjZGHXPZCwwb_cJ2AXQmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to