You can use the DataTable#getFilteredRows method to return an array of row 
indices that match your filter criteria, and then pass that array to a 
DataView, which you can then use to draw your chart:

// response is the response from your query
var data = response.getDataTable();

// get all rows where column 0 is "Foo" and column 1 is >=0 and <= 10
var filteredRows = data.getFilteredRows([{
    column: 0,
    value: 'Foo'
}, {
    column: 1,
    minValue: 0,
    maxValue: 10
}]);

// create a DataView
var view = new google.visualization.DataView(data);
view.setRows(filteredRows);

// draw your chart with the view
var chart2 = new 
google.visualization.BarChart(document.getElementById('chart2_div'));
chart2.draw(view, {width: 600, height: 400, is3D: true});

On Sunday, August 31, 2014 4:49:44 PM UTC-4, Craig Pearce wrote:
>
> I've been working through the documentation quite a bit for the last few 
> days.  I can query my google spreadsheet and produce a chart with the 
> query.setQuery (); to return a specific group of data (through SQL-like 
> request).  
>
> However what I would like to do is load my entire spreadsheet as the 
> datatable, then query it for each specific visualization (each viz needs 
> different data).
>
> For example, instead of dataSourceUrl below, what can I do to query the 
> dataTable instead?
>
> function drawVisualization() {
>     google.visualization.drawChart({
>        "containerId": "visualization_div",
>        "dataSourceUrl": "link to google spreadsheet",
>        "query":"select G, count(H) group by G",
>        ..........
>
> Or is there an option to query within the following code
>
> var chart2 = new 
> google.visualization.BarChart(document.getElementById('chart2_div'));
>   chart2.draw(data, {width: 600, height: 400, is3D: true,})
>
>
> Thanks for any help you can provide.
>

-- 
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.

Reply via email to