I'm trying to pass a variable to a google visualisation method but it keeps bombing out with an error if I use a variable but works fine if I type the string. What am I missing here?
This works:
var filterdata = new google.visualization.DataView(data)
filterdata.setRows(
filterdata.getFilteredRows([{column: 0, value: 'someval'}])
);
This doesn't work:
filteredrows = "[{column: 0, value: 'someval'}]";
var filterdata = new google.visualization.DataView(data)
filterdata.setRows(
filterdata.getFilteredRows(filteredrows)
);
The error I'm getting is:
"Uncaught Error: columnFilters must be a non-empty array"
EDIT:
I'm trying to build an array / string to pass all the dashboard control states as filter conditions for getfilteredrows(). Below is the code I'm using to build the array. I've also tried to create a string but either way it's not accepted...
control_states = [ctrl1.getState(),ctrl2.getState(),ctrl3.getState()];
var filteredrows = {};
var cnt = 0;
for (var i = 0; i < control_states.length; i++) {
var picker_state = control_states[i]
for (var j = 0; j < picker_state.selectedValues.length; j++) {
filteredrows[cnt] = "column: " + i + ", value: '" + picker_state.selectedValues[j] + "'";
cnt += 1;
};
};