Hi again,
I have a problem making the range filter work.
Maybe it because the range filter works only with a given column and not 
with pivot table like I did?
Here is my code:

function drawSecondChart(TwoDTable){ 
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 < TwoDTable.getNumberOfColumns(); i++) {
        columnsTable.addRow([i, TwoDTable.getColumnLabel(i)]);
        initState.selectedValues.push(TwoDTable.getColumnLabel(i));
    }
    var chart = new google.visualization.ChartWrapper({
        chartType: 'LineChart',
        containerId: 'chart_div',
        dataTable: TwoDTable,
        options: {
            //title: 'Foobar',
            width: 600,
            height: 400
        }
    });
    
    chart.draw();
    
    var columnFilter = new google.visualization.ControlWrapper({
        controlType: 'CategoryFilter',
        containerId: 'colFilter_div',
        dataTable: columnsTable,
        options: {
            filterColumnLabel: 'colLabel',
            ui: {
                label: 'Columns',
                allowTyping: false,
                allowMultiple: true,
                selectedValuesLayout: 'belowStacked'
            }
        },
        state: initState
    });
    
var slider = new google.visualization.ControlWrapper({
    controlType: 'NumberRangeFilter',
    containerId: 'rangeFilterDive',
dataTable: TwoDTable,
    options: {
      filterColumnLabel: 'colLabel',
      minValue: 0,
      maxValue: 200000
    }
  });
  
  slider.draw();

    google.visualization.events.addListener(columnFilter, 'statechange', 
function () {
        var state = columnFilter.getState();
        var row;
        var columnIndices = [0];
        for (var i = 0; i < state.selectedValues.length; i++) {
            row = columnsTable.getFilteredRows([{column: 1, value: 
state.selectedValues[i]}])[0];
            columnIndices.push(columnsTable.getValue(row, 0));
        }
        // sort the indices into their original order
        columnIndices.sort(function (a, b) {
            return (a - b);
        });
        chart.setView({columns: columnIndices});
        chart.draw();
    });
    
    columnFilter.draw();
}

Thanks.

On Friday, February 1, 2013 7:52:50 PM UTC+2, Workaholic wrote:
>
> Hi all,
> I'm making a pivot chart from a given datasource added as "table.jpg".
> I'm trying to draw a line chart like the one in "chart.jpg" and add a 
> string filter on it.
>
> What I did to draw the added line chart, was making the table from my 
> datasource look like the one in "customizePivot.jpg".
>
> It works! but causes lots of bugs
> Is there any other way to do this kind of pivot line chart using 
> ChartWrapper(without making the table in "customizePivot.jpg")?
>
> Thanks
>

-- 
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 google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to