Incidentally, my workaround is this: v.setRows(v.toDataTable().getFilteredRows([{column: 0,value:'B'}]).sort(function(a,b){return a-b;}));
But this is really ugly, and if I hadn't carefully checked the results, I would have expected the original code to work as expected. Can someone tell me what I was doing incorrectly? On Jun 22, 1:05 pm, NA <nabeel.a...@gmail.com> wrote: > I am having a problem when filtering then sorting a data view. In the > example below, I have the two lines: > > v = new google.visualization.DataView(data); > v.setRows(v.getFilteredRows([{column:0,value:'B'}])); > v.setRows(v.getSortedRows([{column:1,desc:false}])); > > I create a view, then filter it so that it only includes rows with a > value of 'B'. I use setRows to set those filtered rows to be the rows > of the view. > > I then sort the view, again setting those sorted rows to be the view's > new rows. I then display the view it in the Table. > > I am expecting to only see the rows with B in them. But instead, I > get a row with A in it. > > If I just filter, I get the B row as expected. So I'm not sure why, > when I sort that view, I don't still get the B row. > > Am I doing something obviously wrong here? > > function drawVisualization() { > // Create and populate the data table. > var data = new google.visualization.DataTable(); > data.addColumn('string', 'Name'); > data.addColumn('number', 'Height'); > data.addColumn('boolean', 'Smokes'); > data.addRows(3); > data.setCell(0, 0, 'A'); > data.setCell(1, 0, 'A'); > data.setCell(2, 0, 'B'); > data.setCell(0, 1, 174); > data.setCell(1, 1, 523); > data.setCell(2, 1, 86); > data.setCell(0, 2, true); > data.setCell(1, 2, false); > data.setCell(2, 2, true); > > // Create and draw the visualization. > visualization = new > google.visualization.Table(document.getElementById('table')); > > v = new google.visualization.DataView(data); > > v.setRows(v.getFilteredRows([{column:0,value:'B'}])); > v.setRows(v.getSortedRows([{column:1,desc:false}])); > > visualization.draw(v, null); > > > > > > > > } -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To post to this group, send email to google-visualization-api@googlegroups.com. To unsubscribe from this group, send email to google-visualization-api+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.