Closed ANteiKA closed 9 years ago
This is a feature, and documented.
Note: a grouping intersects the crossfilter's current filters, except for the associated dimension's filter. Thus, group methods consider only records that satisfy every filter except this dimension's filter. So, if the crossfilter of payments is filtered by type and total, then group by total only observes the filter by type.
https://github.com/square/crossfilter/wiki/API-Reference#dimension_group
Idea being that usually you don't want a chart's data to disappear when you are brushing that chart.
The standard workaround is to create an identical dimension and filter that one instead.
Thanks ! I had understood it was a feature, but was wondering how to modify this behavior. According forums posts, I think I am not the only one looking for a solution where the associated dimension of the filtered group should be also updated. May be a dimension.reset flag or function could be useful ?
Your workaround works perfectly also, and it saved my day ! Many thanks.
The working solution can be seen here : http://jsfiddle.net/ewm76uru/30/ If it may helps.
Hello,
I've used crossfilter+dc.js to create a multiple tags filter, to use it on this kind of data :
var data = [ {id:1, author:'foo', tags: ['tag1','tag2','tag3']}, {id:2, author:'foo', tags: ['tag3']}, {id:3, author:'foo', tags: ['tag1']}, {id:4, author:'bar', tags: ['tag2','tag3']}, {id:5, author:'bar', tags: ['tag3']}, {id:6, author:'bar', tags: ['tag2','tag3']}, {id:7, author:'bar', tags: ['tag1','tag2']} ];
The goal is to filter items thanks to tags. It works mostly, as seen here : http://jsfiddle.net/ewm76uru/29/
Unfortunately, when I filter data by selecting a tag, the tag count is not updated according the filtered items. To sum up, all groups are updated, except the one which has been used to filter the data.
Said differently, reduce(reduceAdd, reduceRemove, reduceInitial) is is not called if the data have been filtered by tags ; whereas it is called on all other filters.
Is there a solution or a function to force a group to be updated ?
Thanks.