When you click on an already selected slice, the slice is removed from the
selection, so when you call the getSelection method, it returns an empty
array. Attempting to access a property of an element in an empty array
will throw an exception. There are two ways you can handle this.
1) you can test to see whether anything is selected before trying to use
the selected value, ie:
function selectEvent1() {
var selection = chart1.getSelection();
if (selection.length > 0) {
selected_data = data1.getValue(selection[0].row, 0);
change_department(selected_data);
}
}
2) you can unset the selection after doing all your processing. This will
ensure that when a user clicks a slice, there will always be a selected
element:
function selectEvent1() {
selected_data = data1.getValue(chart1.getSelection()[0].row, 0);
change_department(selected_data);
// calling setSelection with no parameters clears the chart's selections
chart1.setSelection();
}
On Tuesday, October 16, 2012 12:55:25 PM UTC-4, Sangkeun Park wrote:
>
> ...
> ...
> chart1.draw(data1);
> function selectEvent1() {
> selected_data = data1.getValue(chart1.getSelection()[0].row, 0);
> change_department(selected_data);
> }
> google.visualization.events.addListener(chart1, 'select', selectEvent1);
>
>
> --------------------------------------------------------------------------------------------------------
>
> When I click pie-chart it works very well, it call change_Department
> function with parameter.
> However, if I click the already clicked(selected) slice, everything
> stops!! no work. freezing...
> If I remove the first line in the function selectEvent1(), clicking
> selected slice doesn't matter. pie-chart is clickable again although I
> click selected slice.
>
> What I wanna do is that if I click selected slice, then I want to make the
> slice unselected.
> What can I do for it?
>
> problem :
> http://vrc.kaist.ac.kr:8080/bamboo/result_form.jsp?query=hci&restructedQuery=%28hci%29
> (try
> to test on left chart)
>
--
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/-/hlYJrVKW06oJ.
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.