How can I hide dc.js string row values ββif values ββare null
How can we hide if string values ββare null in dc.js after filtering. We have code like this:
var kurum=data.dimension(function(d){return ""+ d.KURUM;});
var kurumGroup=kurum.group().reduceSum(function(d){return +d.INSIDANS});
kurumRowMapChart
.width(300)
.height(200)
.margins({top: 5, left: 10, right: 10, bottom: 20})
.dimension(kurum)
.group(kurumGroup)
.colors(d3.scale.category10())
.elasticX(true)
.ordering(function(d) { return -d.value })
.xAxis().ticks(4);
This code works fine, but we want to hide if it has a filter if the values ββare zero.
thank
source to share
You can create a "fake group" that removes cells containing zeros when called .all()
:
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 that sits between the crossfilter and dc.js that looks like a crossfilter group and filters it on demand.
Here is a somewhat complex example designed to test transitions between different bar numbers:
http://dc-js.github.io/dc.js/transitions/ordinal-row-transitions.html
(Currently, the transitions are not very good, but it shows well remove_empty_bins
.)
source to share