Skip to content

Filter

With this object we can build filters to narrow our queries.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
// Filter by attribute
var event = cf.Filter('venuecity')
                .value(['New York','LA'])

// Filter by time attribute
var event = cf.Filter('saletime')
                .operation('BETWEEN')
                .value([
                '2008-01-12 00:00:00.000',
                '2008-02-12 00:00:00.000',
            ])

// Filter by a metric
var event = cf.Filter('pricepaid')
                .operation('BETWEEN')
                .value([ 1, 10])
Filters expect the name of the field to filter by, the operation and the value, which expects an array of values. These can be strings if the field is an attribute or numbers if is a measurement field.

Filters support three types of operations: IN, NOT IN and BETWEEN. The last one is used as the examples above for numeric and date fields. If no operation is specified then IN will be used as default.

It also supports the label property which is useful when filters are applied across sources with different field names but common field labels. Refer to Interaction Manager for advanced interactions across visualizations.

Server Filters

All filters set to a visualization or query by using .filters(), .filter() or .staticFilters() are server filters. This means that the visualization will query the server again to bring the new filtered data.

Client Filters

This type of filter are set with the use of .clientFilters(). Usually these filters match the same group or field used to aggregate the visualization or query. This way the visual knows how to exclude non-matching data without re-querying the server again.