Lets say I have got this data to push into crossfilter:
[
{user: 'abby', town: 'reading', postcode: 'RG'},
{user: 'ben', town: 'reading', postcode: 'RG'},
{user: 'charlie', town: 'bristol', postcode:'BS'}
]
Note the flattened nature of the the data - the postcode field will always be a mapping from the town field, so whenever town = reading, postcode will = RG etc.
I want to be able to create a 'town' dimension that is sourced from both the town and the postcode fields, so that when I filter on my user dimension, say with 'abby', then the town dimension, when I call group().all()
, will return an array like:
[
{town: 'reading', postcode: 'RG' }
]
What is the correct way to do this?
I know that I could produce a town dimension with something like
var townDimension = myCrossFilter.dimension(function(row) {
return row.town + ':' + row.postcode;
})
And then, after calling group().all() on the filtered dimension, I would have to manually convert the list of resulting strings into a list of {town, postcode} objects.
But is there support within crossfilter for doing this?