As you correctly describe, the listener tells you which row was selected with respect to the filtered chart (row 0 of the filtered chart), but you resolve that row number against the overall datatable when you call data.getValue().
To fix the problem, resolve the value against the filtered datatable itself. Try replacing: var selectedItem = chart.getChart().getSelection()[0]; var value = data.getValue(selectedItem.row, 0); with var selectedItem = chart.getChart().getSelection()[0]; var value = *chart.getDataTable()*.getValue(selectedItem.row, 0); In the context of dashboards, each chartwrapper that is part of it holds a reference to the 'filtered' datatable that is was drawn with. You can access it via its standard getDataTable() method, as shown above. -- R. On 13 October 2011 11:12, Andrea <[email protected]> wrote: > Hi Everybody, I've a problem. > > I am drawing a column chart with a NumberRangeFilter (slider) in this > way; > > //... > dashboard.bind(slider, myChart); > dashboard.draw(dataTable); > > > I added a listener: > > google.visualization.events.addListener(myChart, 'select', > selectHandler); > function selectHandler() { > var selectedItem = chart.getChart().getSelection()[0]; > var value = data.getValue(selectedItem.row, 0); > alert('The user selected ' + value); > } > > > Everything works fine. But when I use the slider to filter my data the > listener dosn't work anymore. The problem is that the Listener > considers as row 0 the first bar of the "filterd chart", but it refers > to the "unfiltered data table". So the item selection does not work > when I use the slider. > > i.e. > > DataTable: > item value > A 5 > B 3 > C 2 > > If I use the slider to see value < 5 I get a column chart with only > bar B and bar C. But when I click on the first bar of the chart (bar > B) the event listener returns the first row of DataTable: the item A. > > How can I fix this? > > Tanks. > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > 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. > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. 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.
