If you want to use the NumberRangeFilter on the chart, you should bind them
together in a Dashboard:
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, don't set this
options: {
//title: 'Foobar',
width: 600,
height: 400
}
});
// chart.draw(); don't call this
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, don't set this
options: {
filterColumnLabel: 'colLabel',
minValue: 0,
maxValue: 200000
}
});
// slider.draw(); don't call this
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();
// create a dashboard; you will need a div with the ID used here in
your HTML, and this div should contain both the chart and control divs
var dashboard = new
google.visualization.Dashboard(document.getElementById('dashboard_div'));
dashboard.bind([slider], [chart]);
dashboard.draw(TwoDTable);
}
On Monday, February 4, 2013 1:51:10 AM UTC-5, Workaholic wrote:
>
> I'm trying to evade repivoting my data table
>
>
> 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 [email protected].
To post to this group, send email to [email protected].
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.