This was very very helpful. Thanks much Andrew!
On Friday, July 4, 2014 4:34:40 PM UTC-7, Andrew Gallant wrote:
>
> You can do this with a single view; you need to get the sorted rows from
> the view and then translate them back into the table row indices.
>
> var view18 = new google.visualization.DataView(dt);
> view18.setRows(dt.getFilteredRows([{'column': 2, 'value': 'Male'}]));
> var sortedViewRows = view18.getSortedRows(3);
> var sortedTableRows = [];
> for (var i = 0; i < sortedViewRows.length; i++) {
> sortedTableRows.push(view18.getTableRowIndex(sortedViewRows[i]));
> }
> view18.setRows(sortedTableRows);
>
> Using two views makes for cleaner code, though:
>
> var filterView = new google.visualization.DataView(dt);
> filterView.setRows(dt.getFilteredRows([{'column': 2, 'value': 'Male'}]));
> var view18 = new google.visualization.DataView(filterView);
> view18.setRows(filterView.getSortedRows(3));
>
> On Friday, July 4, 2014 5:21:02 PM UTC-4, AM wrote:
>>
>> Is there a way to both sort and filter the data in a view?
>>
>>
>> var view18 = new google.visualization.DataView(dt);
>> view18.setRows(dt.getFilteredRows([{'column': 2, 'value': 'Male'}]));
>> view18.setRows(dt.getSortedRows(3));
>> Chart18.setDataTable(view18);
>> Chart18.draw();
>>
>> I'm finding that this only allows for the the filter.
>>
>
--
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.