You can use the #getFilteredRows method to get a list of rows that match
your filter, but you can only do "and" type matches (eg, value 1 = 'a' and
value 2 < 5), you cannot do "or" type matches (eg, value 1 = 'a' or value
1 = 'b'). For that, you have to do multiple filters and combine the
results, removing any extra duplicate matches, eg:
var matchA = data.getFilteredRows([{column: 0, value: 'A'}]);
var matchB = data.getFilteredRows([{column: 0, value: 'B'}]);
var matchedRows = a.concat(b);
matchedRows.sort();
// remove all duplicates
for (var i = matchedRows.length - 1, val; i >= 0; i--) {
if (matchedRows[i] != val) {
// if its not a duplicate, update val
val = matchedRows[i];
}
else {
if it is a duplicate, splice it out of the array
matchedRows.splice(i, 1);
}
}
On Saturday, May 10, 2014 3:37:08 PM UTC-4, cyb wrote:
>
> Hi,
>
> ok all works now but i have another question :)
>
> i want build a category filter for my xAxis..
>
> for example if i have this table:
>
> Value1, Value 2
>> A,1
>> B,2
>> C,3
>> D,4
>> E,5
>> F,6
>
>
> then i want show only for example the values for B,C and D..
>
> i know i can do this with the category filter from the dashboard but can i
> build my own filter with maybe the getFilteredRows([{column: 3, value: 'A'}
> ) Method ?
>
> can i filter there for more then one value ?
>
> and second quesetion:
>
> is there an option to destroy the whole chart ? so that no chart is
> displayed ? or can i build an empty dummy chart ?
>
> Best regards
>
>
> Am Montag, 5. Mai 2014 18:11:24 UTC+2 schrieb cyb:
>>
>> Hi,
>>
>> i use a chartWrapper to display different charts (Line,Colum,Area,Pie and
>> so on) and i can filter dates and numbers without any problem but if i
>> switch to discrete mode then the filtering did no longer work..
>>
>> i build the filter view for my DataWrapper like this:
>>
>> Data:
>>
>>> date,New York,San Francisco,Austin,Country
>>> 20111001,10,20,30,A
>>> 20111002,40,50,60,B
>>> 20111003,70,80,90,C
>>> 20111004,100,110,120,D
>>
>>
>> var dataTable=new google.visualization.DataTable(DATA);
>>> var filteredView ={columns : 1,2,3, rows :
>>> dataTable.getFilteredRows([{column:1, minValue: 40, maxValue: 70}])};
>>
>>
>> For example i want filter on the xAxis (New York) all values between 40
>> and 70.. this works if i have no discrete mode..
>>
>> but if i change the Column "New York" from type number to string (is this
>> the only method to activate the discrete mode? or is there an option where
>> i must not change the type ? ) the filtering did not work. I do the
>> switching to discrete mode like that:
>>
>> var View =[
>>> {
>>> type: 'string',
>>> label: dataTable.getColumnLabel(1),
>>> calc: function (dt, row) {
>>> return dt.getFormattedValue(row, 1);
>>> }
>>> }
>>> ];
>>> View .push.apply(View ,[2,3]); //Adds the values
>>> from a second array to the first array
>>> var newView={columns: View }; /
>>
>>
>>
>>
>> i have the same problem with the PieChart, there is per default the first
>> column a string so i can not do any filtering.
>>
>> how can i solve this problem ?
>>
>
--
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.