If you have a DataView that you want to sort, you can call the
getSortedRows<https://developers.google.com/chart/interactive/docs/reference#DataTable_getSortedRows>method
of the view to get an array of row indices, sorted by whatever
criteria you specify in the sort call. You can then take the first 5
entries in this array of rows and feed it to a new DataView to draw your
chart with:
var sortedRows = view.getSortedRows({column: 1, desc: true});
if (sortedRows.length > 5) {
sortedRows.splice(5, sortedRows.length - 5);
}
var view2 = new google.visualization.DataView(view);
view2.setRows(sortedRows);
//...
chart.draw(view2, options);
On Monday, February 24, 2014 2:49:46 PM UTC-5, Ashok Kumar wrote:
>
> Hi,
>
> I have a requirment to sort a dataview and then generate a graph out of
> the top 5 rows of the sorted dataview table.
>
> Is this possible to achieve without using a query as i am using CSV as my
> external data source and also my existing chart code is in java script
>
> Regards,
> ashok
>
--
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/groups/opt_out.