Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the current filter for a crossfilter dimension?

Tags:

crossfilter

I have a crossfilter.dimension. How do I get the current filter set on it (for example if it was set by a brush from a chart)?

Example:

dimension.filterRange([1,15]) // returns dimension

Given this filtered dimension, how do I get the values 1 and 15 out?

like image 318
jlivni Avatar asked Feb 05 '15 21:02

jlivni


1 Answers

Stumbled on this old question because it is the top-voted unanswered crossfilter question, with 1k views!

This feature was contributed by Thomas Gillet in 1.4.5 as dimension.currentFilter()

The tough remaining problem: when you get beyond filterExact and filterRange, the more complex filters use filterFunction. You might be able to retrieve the function but functions are essentially opaque.

For example, if you are using dc.js, it will generate a filter function when

  • multiple items are selected in pie chart, row chart, or bar chart with ordinal dimension
  • the chart has a two-dimensional filter, like the scatter plot or the heatmap

For this reason, if you're using dc.js, you should use chart.filters() instead.

like image 159
Gordon Avatar answered Oct 02 '22 05:10

Gordon