How can we hide if row chart values equal zero in dc.js after filtering .We have a code like this:
var kurum=data.dimension(function(d){return \"\"+ d.KU
You can create a "fake group" which removes the bins containing zeros when .all()
is called:
function remove_empty_bins(source_group) {
return {
all:function () {
return source_group.all().filter(function(d) {
return d.value != 0;
});
}
};
}
using it like this:
var filtered_group = remove_empty_bins(kurumGroup);
kurumRowMapChart.dimension(kurum)
.group(filtered_group)
...
https://github.com/dc-js/dc.js/wiki/FAQ#remove-empty-bins
The idea is to create an object which sits between crossfilter and dc.js which looks like a crossfilter group and filters it on demand.
Here is a somewhat complicated example intended to test the transitions between varying numbers of bars:
http://dc-js.github.io/dc.js/transitions/ordinal-row-transitions.html
(Currently the transitions are not very good but it demonstrates remove_empty_bins
well.)
@Gordon: Great answer! remove_empty_bins() worked for me! :)
I had to use d.value.count instead of d.value but I assume this depends on which group-reduce function you are using:
return d.value.count !== 0;