mosaic icon indicating copy to clipboard operation
mosaic copied to clipboard

How do you filter data in a particular plot?

Open tmcw opened this issue 1 year ago • 1 comments

From the documentation, I can see examples of filtering the entire dataset up-front, like in the example: https://uwdata.github.io/mosaic/examples/ in which we provide { where: "Symbol = 'AAPL'" } to filter just for AAPL.

I can't find an example or documentation of loading a larger dataset and showing subsets of it. Like, if in that example, we wanted a page in which we had AAPL, MSFT, and a few other stocks or whatever - in separate plots, how would that work? We probably wouldn't want to set up the executor again?

There's documentation for a query builder, but I don't see how this hooks up to charts: https://uwdata.github.io/mosaic/sql/

There's documentation for methods that seem like they create filtered sub-tables from parquet files: https://uwdata.github.io/mosaic/api/sql/data-loading.html

Is there a way to show a chart of data from a parquet file, but not all the data in the parquet file?

tmcw avatar Sep 09 '23 20:09 tmcw

The filterBy property can be used to push down a client-specific filtering predicate. You can add your own predicate to a selection that is passed as a client filterBy parameter. However, this has the limitation that the predicate will then be applied to all clients subscribed to that selection. We've considered support for an additional "static" filtering predicate but have not added it yet. We're open to ideas and suggestions for expanding the API in an elegant way!

In the meantime, Plot also has a filter channel that vgplot respects. However, this uses a JavaScript predicate function applied to the retrieved query results, and so will not be pushed down to the database.

jheer avatar Sep 13 '23 15:09 jheer