Filter package:hvega

Type of filtering operation. See the Vega-Lite documentation for details. These can also be included into a BooleanOp expression using FilterOp and FilterOpTrans (as of version 0.4.0.0).
Adds the given filter operation a list of transformations that may be applied to a channel or field.
transform
. filter (FEqual "Animal" (Str "Cat"))
Filter operations can combine selections and data predicates with BooleanOp expressions (and as of 0.4.0.0, FilterOp and FilterOpTrans can be used to lift the Filter type into boolean expressions):
transform
. filter (FCompose (And (Expr "datum.Weight_in_lbs > 3000") (Selection "brush")))
The Vega expression documentation describes the supported format (e.g. the requirement to precede column names with "datum.").
Convert a Filter into a BooleanOp so that it may be used as part of a more complex expression. For example (using & to apply FilterOp to a filter):
trans = transform
. filter (FCompose
(And
(FValid IMDB_Rating & FilterOp)
(FValid Rotten_Tomatoes_Rating & FilterOp)
)
)

Combine a data-transformation operation with a filter before converting into a boolean operation. This can be useful when working with dates, such as the following exampe, which aggregates a set of dates into years, and filters only those years between 2010 and 2017 (inclusive). The final expression is converted back into a BooleanOp with FCompose (combined using &).
filter (FRange "date" (NumberRange 2010 2017)
& FilterOpTrans (MTimeUnit (TU Year))
& FCompose
)

A pair of filter range data values, used with FRange.
Here we show distributions of the four main numeric quantities in the dataset - position, magnitude, and prallax - using the totalEnc encoding, and add a second layer which repeats this data but with a different color (selectedEnc), and that is tied to the interval-selection along the x axis (ChX). Open this visualization in the Vega Editor Selecting a small range of parallax values in the fourth plot highlights the associated data in the other three plots.
let sel = selection . select "brush" Interval [ Encodings [ ChX ] ]

filterTrans = transform . filter (FSelection "brush")

-- borrow a function from Elm
pQuant = PmType Quantitative

totalEnc = encoding
. position X [ PRepeat Column, pQuant ]
. position Y [ PAggregate Count, pQuant ]

selectedEnc = totalEnc
. color [ MString "goldenrod" ]

in toVegaLite
[ repeat [ ColumnFields [ "RA_ICRS", "DE_ICRS", "Gmag", "plx" ] ]
, specification $
asSpec
[ gaiaData
, layer
[ asSpec [ mark Bar [], totalEnc [] ]
, asSpec [ sel [], filterTrans [], mark Bar [], selectedEnc [] ]
]
]
]