CrossFilter Transform

The crossfilter transform maintains a filter mask for multiple dimensional queries, using a set of sorted indices. This transform can be used in conjunction with the resolvefilter transform to enable fast interactive querying over large data sets. This transform is inspired by the Crossfilter library developed by Mike Bostock and collaborators.

Transform Parameters

Property Type Description
fields Field[ ] Required. An array of data fields to filter. The same field may be included more than once to specify multiple queries.
queries Array[ ] Required. An array of per-field range queries. Each entry must resolve to a two-element number array, indicating the minimum (inclusive) and maximum (exclusive) values that should pass through the filter.
signal String If defined, binds the computed filter mask to a signal with the given name.

This transform writes to the property _index on each input data object. If other transforms overwrite this property, the resulting behavior is undefined.

Usage

This example cross-filters the delay, time, and distance fields in a data set of flights. The crossfilter transform sets up the filters, using range queries defined by signal values. The three derived data sets use resolvefilter transforms to filter the data, in each case ignoring one of the fields. For example, the "filterTimeDistance" data set filters the data by the time and distance queries, ignoring the delay query.

{
  "signals": [
    { "name": "delayRange", "value": [-60, 180] },
    { "name": "timeRange", "value": [0, 24] },
    { "name": "distanceRange", "value": [0, 2400] },
  ],
  "data": [
    {
      "name": "flights",
      "url": "data/flights-200k.json",
      "transform": [
        {
          "type": "crossfilter",
          "signal": "xfilter",
          "fields": ["delay", "time", "distance"],
          "query": [
            {"signal": "delayRange"},
            {"signal": "timeRange"},
            {"signal": "distanceRange"}
          ]
        }
      ]
    },
    {
      "name": "filterTimeDistance",
      "source": "flights",
      "transform": [
        {
          "type": "resolvefilter",
          "filter": {"signal": "xfilter"},
          "ignore": 1,

        },
        ...
      ]
    },
    {
      "name": "filterDelayDistance",
      "source": "flights",
      "transform": [
        {
          "type": "resolvefilter",
          "filter": {"signal": "xfilter"},
          "ignore": 2
        },
        ...
      ]
    },
    {
      "name": "filterDelayTime",
      "source": "flights",
      "transform": [
        {
          "type": "resolvefilter",
          "filter": {"signal": "xfilter"},
          "ignore": 4
        },
        ...
      ]
    }
  ]
}