I'm pretty new to Crossfilter, so my apologies.
I am working on a project where I am bringing data into the page and then permitting users to filter the data using select elements. Each select filter corresponds to a Crossfilter dimension. Based on the selected filter(s), the appropriate data is displayed in the page. I have that all working correctly, including the use of multiple filters at the same time (and each filter can contain multiple values).
What I would like to do is display the data organized by a selected group. For example, if my data has 3 columns: Office, Department and Gender, the user may filter on Office = [New York, Atlanta] and Gender = [Female]. The user can then group the results by Department (or another column). For ex, if there are 20 out of 100 matches based on the filters listed above, those results can be grouped by Department as follows: 8 Marketing, 7 Sales and 5 in IT.
(The order of the grouping is not relevant right now.)
There are other Departments in the data that are not included in the filtered results (like HR, Security, Operations, etc.)
At the time that the code has applied the filters and displayed the results, I don't seem to have a way to show the unique Department values that are associated with just those 20 items. When I do something like this:
deptDimension.group().all().forEach(function(d) {
It lists ALL of the Departments from all 100 records, even ones that are not in the current filtered results.
How do I get a list of unique values from a given dimension that will respect the existing filters?
Also, if anyone knows how to iterate over the results in the order of the groups/unique values for the Department dimension, that would be helpful too.