nevermind, i figured it out.
It turns out, it is the query in the Chartwrapper that appears to be the 
problem. There may be a better way but I had to send the query in a 
separate function and use a handleQueryResponse function to putit into a 
datatable and do everything else

here is the new code
google.load('visualization', '1', {packages: ['controls']});
google.setOnLoadCallback(initialize);


function initialize() {
  var opts = {sendMethod: 'auto'};
  // Replace the data source URL on next line with your data source URL.
  var query = new 
google.visualization.Query('https://docs.google.com/a/google.com/spreadsheet/ccc?key=1uWxegqnxB0ZxAl3FmiNuI00A09Vbir_W9RqxE-pGnRQ',
 
opts);

  // Optional request to return only column C and the sum of column B, 
grouped by C members.
  query.setQuery('select A,B,C,D,E where B is not null');

  // Send the query with a callback function.
  query.send(handleQueryResponse);
}

function handleQueryResponse(response) {
  // Called when the query response is returned.
  
  if (response.isError()) {
    alert('Error in query: ' + response.getMessage() + ' ' + 
response.getDetailedMessage());
    return;
  }

  var data = response.getDataTable();
  
  var Chart = new google.visualization.ChartWrapper({
    chartType:'LineChart',
    dataTable:data,
    containerId:'chart_div',
    options:{
      title: 'Calls Offered',
      curveType: 'function',
      theme:'maximized',
          width: 550,
          height: 300
    }
  });
  
  

    var columnsTable = new google.visualization.DataTable();
    columnsTable.addColumn('number', 'colIndex');
    columnsTable.addColumn('string', 'colLabel');
    var initState= {selectedValues: []};
    // put the columns into this data table (skip column 0)
    for (var i = 1; i < data.getNumberOfColumns(); i++) {
        columnsTable.addRow([i, data.getColumnLabel(i)]);
        // you can comment out this next line if you want to have a default 
selection other than the whole list
        initState.selectedValues.push(data.getColumnLabel(i));
    }
    // you can set individual columns to be the default columns (instead of 
populating via the loop above) like this:
    // initState.selectedValues.push(data.getColumnLabel(4));
    

    
    var columnFilter = new google.visualization.ControlWrapper({
        controlType: 'CategoryFilter',
        containerId: 'colFilter_div',
        dataTable: columnsTable,
        options: {
            filterColumnLabel: 'colLabel',
            ui: {
                label: 'Columns',
                allowTyping: false,
                allowMultiple: true,
                allowNone: false,
                selectedValuesLayout: 'aside'
            }
        },
        state: initState
    });
    
    function setChartView () {
        var state = columnFilter.getState();
        var row;
        var view = {
            columns: [0]
        };
        for (var i = 0; i < state.selectedValues.length; i++) {
            row = columnsTable.getFilteredRows([{column: 1, value: 
state.selectedValues[i]}])[0];
            view.columns.push(columnsTable.getValue(row, 0));
        }
        // sort the indices into their original order
        view.columns.sort(function (a, b) {
            return (a - b);
        });
        Chart.setView(view);
        Chart.draw();
    }
    google.visualization.events.addListener(columnFilter, 'statechange', 
setChartView);
    
    setChartView();
    columnFilter.draw();
}

Thanks.

Now I just need to figure out how to do this with a bunch or charts from 
different sheets in the same Spreadsheet using the same filter (same 
headers).




On Thursday, September 22, 2011 at 6:52:36 AM UTC-4, pb wrote:
>
> Hi, 
>
> I would like to filter data that is coming in from a sourceURL, i 
> don't seem to understand the concept of needing to use setView() to 
> bring imported data into a dataView. Can anyone give a clear and 
> simple example of how this is done please? Amazed that this is shown/ 
> written anywhere clear enough in the docs. 
>
> Help is always appreciated in advance. 
>
> pb

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