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 [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/6fba1dd7-00b8-4e85-bbcc-ff60a173e170%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.